Repository navigation
fix(agent): keep batched tool calls in order around non-read-only calls - #1291
Merged
Merged
Conversation
Batched tool calls ran fully concurrently, so a Read issued after a Write in the same turn could run before the Write finished and return NOT_FOUND. Both schedulers (ApprovingTools and executeToolCallsParallel) now share CallOrder: read-only calls still run together, but any other call waits for every earlier call, and later calls wait for it. Approval prompts still overlap execution (#609); only execution is ordered. The read-only set is the existing ReadOnly subagent toolset, hoisted to agentdomain.ReadOnlyTools. Fixes #1290
Contributor
|
🎉 This PR is included in version 0.207.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Fixes #1290.
Root cause
Tool calls from one assistant turn ran fully concurrently in both schedulers:
ApprovingToolsState.spawnExecution(approval path, including auto-accept) andAgent.executeToolCallsParallel(no-approval path, e.g.--mode auto). AReadissued after aWritein the same batch could run before theWritefinished and returnNOT_FOUND.Fix
New
states.CallOrder(internal/agent/states/call_order.go), used by both schedulers:The read-only set is the existing ReadOnly subagent toolset, moved to
agentdomain.ReadOnlyToolsand reused byListToolsForMode.Trade-off: separate
BashorAgentcalls in one batch now run in sequence. Parallel subagents still run together via theAgenttool'stasksarray.Tests
TestApprovingToolsState_ReadWaitsForEarlierWrite, an approvedWritefollowed by an ungatedRead.TestAgentReadAfterWriteInSameBatchSeesWrite, headless--mode autoagainst the tokenless mock; theReadresult must contain what theWritewrote.main(the e2e test failed 3 out of 3 runs) and pass with the fix.internal/agent/...passes under-race, the full e2e suite passes, and lint reports 0 issues.