Repository navigation
Conversation
…p sees the file (/tmp and /private/tmp) and the overwritten content (#2125) The AI SDK dispatches every tool call of one assistant step concurrently, so a read that follows a shell write in the same step stats the file before the shell has written it. Extends the upstream session tools suite (copied into the overlay) with the write-then-read and overwrite-then-read cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t sees files a shell call just wrote (#2125) Root cause: the AI SDK starts each tool call of an assistant step as soon as it streams in, so when the model emits a shell write and a read of the same file in one step, the read stats the file before the shell has written it. That gives "File not found" for a file that exists a moment later, or the old bytes of an image being overwritten. In the local session database, all 268 failed reads from 2026-10-26 to 2026-11-04 shared their step with an earlier bash call, and in 266 of them that bash call was still running when the read began. Path spelling (/tmp vs /private/tmp) and caching are not involved: the read path has no cache, and later reads succeed under either spelling. Fix: SessionTools.resolve (one per step) tracks the calls it has dispatched; a read waits for the earlier ones to settle before it runs. Other tools still run concurrently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
jacktrnr
marked this pull request as ready for review
November 23, 2026 22:02
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.
Closes #2125
Root cause
This is a race between tool calls in one step. Path canonicalization and caching are not involved.
The AI SDK starts each tool call of an assistant step as soon as it streams in, so tool calls in one step run concurrently. When the model emits a shell write (a plotting script,
cp, a> fileredirect) and areadof that file in the same step, the read stats the file before the shell has written it:Evidence from a read-only sweep of the local session database (2026-10-26 to 2026-11-04):
bashcall.bash: ... > /tmp/k2.txt; wc -l /tmp/k2.txtandread /tmp/k2.txtwere created 18 ms apart, and the read failed. The next step read/private/tmp/k2.txtfine. In the same session, an in-repo path (.k3.txt) failed in the same way, so/tmpis not the cause.The
/tmpvs/private/tmppattern only reflects how agents retried: a retry in a later step succeeds under either spelling. The read path has no file or attachment cache.Fix
SessionTools.resolveis called once per step. It now keeps track of the calls it has dispatched, and areadwaits for the earlier calls in that step to settle (Promise.allSettled) before it runs. Other tools still run concurrently, and reads never block other calls, so there is no new deadlock path. The step already waits for every call to finish, so total step time does not change.The change is in
packages/app-bundle/overlay/packages/opencode/src/session/tools.ts, which is now an overlay copy of the upstream file. The manifest was regenerated withrefresh_manifest.mjs, anddrift_gate.mjspasses.Tests
test/session/tools.test.tsis now an overlay copy of the upstream suite, extended with:/tmp→/private/tmp, and under/private/tmp→/tmp. On non-macOS hosts both spellings are the same directory.RED before the fix: all 4 new tests failed with
File not found: /tmp/oc-2125-…/fig.pngandReceived: "old figure". GREEN after the fix: 5 of 5 pass, including the existing upstream test.Scope note: only
readwaits. Other tools (grep, glob, MCP tools) are out of scope for this issue.🤖 Generated with Claude Code