Summary
When a file is read through any sandbox backend (BaseSandbox / its subclasses in libs/deepagents/src/backends/sandbox.ts), the output shows line numbers twice on every line, e.g.:
1 1 import { foo } from "bar";
2 2 const x = 1;
instead of the expected single column:
1 import { foo } from "bar";
2 const x = 1;
Root cause
Line numbering is applied in two places for sandbox reads:
-
The backend. buildReadCommand() in libs/deepagents/src/backends/sandbox.ts builds an awk command that prepends line numbers itself:
awk 'NR >= ${start} && NR <= ${end} { printf "%6d\t%s\n", NR, $0 }' ${quotedPath}
-
The middleware. The shared read_file tool in libs/deepagents/src/middleware/fs.ts (line ~773) unconditionally re-numbers whatever content the backend returns:
let formatted = formatContentWithLineNumbers(content, offset + 1);
Proposed fix
Change the awk command in buildReadCommand() to emit only the line content:
awk 'NR >= ${start} && NR <= ${end} { printf "%s\n", $0 }' ${quotedPath}
Summary
When a file is read through any sandbox backend (
BaseSandbox/ its subclasses inlibs/deepagents/src/backends/sandbox.ts), the output shows line numbers twice on every line, e.g.:instead of the expected single column:
Root cause
Line numbering is applied in two places for sandbox reads:
The backend.
buildReadCommand()inlibs/deepagents/src/backends/sandbox.tsbuilds anawkcommand that prepends line numbers itself:The middleware. The shared
read_filetool inlibs/deepagents/src/middleware/fs.ts(line ~773) unconditionally re-numbers whatever content the backend returns:Proposed fix
Change the
awkcommand inbuildReadCommand()to emit only the line content: