Repository navigation
fix(deepagents): return backend errors from the file tools to the model - #1082
Closed
Baihao Wang (byhow) wants to merge 2 commits into
Closed
Baihao Wang (byhow) wants to merge 2 commits into
Baihao Wang (byhow) wants to merge 2 commits into
Conversation
… model When the sandbox backend rejected a command, the error left the `execute` tool and ended the whole run. The tool now returns it as an error tool message, as the other filesystem tools do for backend errors, so the model can read it and try another command. Interrupts, other graph control flow and aborted runs still propagate. The abort check that the parent notifier already used moves to the shared middleware utils so both callers use the same one.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 646f96f The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
deepagents-acp
deepagents
@langchain/sandbox-standard-tests
@langchain/daytona
@langchain/deno
@langchain/modal
@langchain/node-vfs
@langchain/quickjs
commit: |
Baihao Wang (byhow)
marked this pull request as ready for review
November 18, 2026 22:27
When a backend method threw inside `ls`, `read_file`, `write_file`, `edit_file`, `delete`, `glob` or `grep`, the error left the tool and ended the whole run. A sandbox request that timed out during a `grep` was enough to do it. Each tool now returns the error as an error tool message, so the model can read it and try something else. The tools make their backend call through one helper, and `execute` uses it in place of its own catch. Interrupts, other graph control flow and aborted runs still propagate. A request timeout raised by the backend's own client is not an aborted run, so it is reported.
execute tool to the modelThis branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a backend throws inside a file tool, the tool now returns the error to the model as an error tool message. This covers
ls,read_file,write_file,edit_file,delete,glob,grepandexecute. Before this change the error left the tool and ended the whole run, so the model never saw what went wrong and could not try something else.Two ways to reach it on a sandbox backend. A command leaves a background job holding stdout open, and the sandbox service rejects the request. Or a
grepover a large tree outlives the sandbox client's request timeout. Either way the backend's client throws. The model now gets a tool message with error status and the contentError:followed by the backend's message. An error a backend returns, and a command that exits non-zero, are unchanged.The catch is in the tools, not in one backend, so it covers every backend that throws, including backends outside this repo. Without it the throw is fatal because the filesystem middleware registers a
wrapToolCallhook, and the tool node rethrows an error that passes through such a hook unless the agent setshandleToolErrors.What to check
callBackendinfs.ts. It is the only new logic. Each tool makes its backend call through it and returns early when it gets a tool message back. The rest of thefs.tsdiff is those call sites, and much of it is re-indentation, so hide whitespace when you read it.isGraphBubbleUpis true for the error or the run was aborted. The parent notifier middleware already used the same pair of checks.TimeoutErrorfrom the backend's own request timeout is reported to the model, because the run's signal is not aborted.wrapToolCallhook. That hook wraps every tool call in the agent, not only this middleware's tools, and it does not run when a tool is invoked directly.toolRetryMiddleware, no longer retries them for that error. Code that invokes a tool directly gets the error text back instead of a rejection. Errors a backend returns already behaved this way.AbortErrorstill propagates even when no signal is aborted, as before. A backend client that times out its own request with that name would still end the run. The backends in this repo useTimeoutErroror their own error types.wasAbortedmoved, unchanged, fromparent_notifier.tstomiddleware/utils.tsso both callers share it. It is not exported from the package.Not in this PR
grepcommand has no time limit or output cap of its own, so a slow search still runs until the client's timeout before the model sees the error.Tests
New cases in
fs.test.ts, on the file's existing mock sandbox backend. For each tool, a backend that rejects yields an error tool message and the tool does not throw. AGraphInterruptand an error namedAbortErrorare rethrown as the same object. ATimeoutErrorfromgrepis reported, and an agent run with a fake model continues to a second model turn after it.wasAbortedhas direct cases inutils.test.ts.Python counterpart: langchain-ai/deepagents#7820
🤖 Generated with Claude Code