Skip to content

fix(deepagents): stop double line numbers in read_file for sandbox backends#439

Open
Alexei Vedernikov (alvedder) wants to merge 1 commit into
langchain-ai:mainfrom
alvedder:alvedder/fix-double-numbers
Open

fix(deepagents): stop double line numbers in read_file for sandbox backends#439
Alexei Vedernikov (alvedder) wants to merge 1 commit into
langchain-ai:mainfrom
alvedder:alvedder/fix-double-numbers

Conversation

@alvedder

Copy link
Copy Markdown
Contributor

Sandbox read() used awk to emit cat-n–style NR + tab + line, and the read_file tool then ran formatContentWithLineNumbers again. Text reads showed two numeric columns e.g.

     1	     1	{
     2	     2		"name": "monorepo",
     3	     3		"version": "1.0.0",
...

This aligns sandbox text read() with FilesystemBackend: raw sliced lines from the backend; one numbering pass in the tool.

Changes

  • buildReadCommand (libs/deepagents/src/backends/sandbox.ts): keep the same existence / empty-file checks and NR range (1-based inclusive slice from 0-based offset/limit); replace numbered printf with { print } so stdout is unnumbered lines only.
  • Docs: Clarify on BaseSandbox.read, FilesystemBackend.read, CompositeBackend.read, and buildReadCommand that text read() returns a raw line slice; cat-n formatting is applied in read_file.
  • Tests (libs/deepagents/src/backends/sandbox.test.ts):
    • Helper + test that read_file output has exactly one tab-separated “line number + body” segment per line (no extra leading number column) when using MockSandbox + createFilesystemMiddleware.
    • MockSandbox: simulate the real awk slice (NR >= start && NR <= end) and return raw joined lines (no prefixes).
    • Assert text reads use awk with { print }.
  • @langchain/sandbox-standard-tests: rename the misleading read() case from “with line numbers” to reflect raw backend output.

Testing

  • pnpm exec vitest run src/backends/sandbox.test.ts --typecheck (and related fs unit tests as appropriate).

Notes

  • Binary reads are unchanged (still via downloadFiles).
  • Callers that depended on numbered strings from backend.read() on sandboxes should switch expectations to raw lines (same as filesystem/state backends); numbering belongs to tool/UI layers that call formatContentWithLineNumbers.

@changeset-bot

changeset-bot Bot commented Apr 8, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a72815c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant