Repository navigation
shelley/loop: repair missing tool results in tool-call order - #362
Open
AndrewFribush wants to merge 1 commit into
Open
AndrewFribush wants to merge 1 commit into
AndrewFribush wants to merge 1 commit into
Conversation
When a turn is interrupted after the model asks for several tools and the next user message lacks some of their results, insertMissingToolResults prepends synthetic "not executed" results for the missing ones. It found them by ranging over a map, so they came out in a different order on each request. The repair is recomputed for every request and never written back to the history, so the same conversation produced different request bytes each time, and the prompt cache missed from the interrupted turn onward on every later request in that conversation. Walk the assistant message's tool calls in their original order instead. A repeated tool-call ID still gets a single result, as before. The new test interrupts six tool calls with one answered and checks the order across 50 repairs; it fails against the old code.
This branch has not been 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.
When a turn is interrupted after the model asks for several tools and the next user message lacks some of their results, insertMissingToolResults prepends synthetic "not executed" results for the missing ones. It found them by ranging over a map, so they came out in a different order on each request.
The repair is recomputed for every request and never written back to the history, so the same conversation produced different request bytes each time, and the prompt cache missed from the interrupted turn onward on every later request in that conversation.
Walk the assistant message's tool calls in their original order instead. A repeated tool-call ID still gets a single result, as before. The new test interrupts six tool calls with one answered and checks the order across 50 repairs; it fails against the old code.
🤖 Generated with Claude Code