fix: correct interleaved tool input deltas and recover command actions from tool results#73
Conversation
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 two related bugs in how tool inputs and display actions are handled.
When an LLM emits interleaved tool calls (ToolCallStart for tool-1, then tool-2, then deltas for both), the delta matching code incorrectly matched deltas to the last started tool instead of using the index field. When tool-1's delta arrived after tool-2's start, the delta was written into tool-2's accumulated input, producing wrong tool inputs.
Fix: Use the index field to match deltas to the correct tool call. Also capture final tool inputs from the MessageDone response body instead of re-parsing accumulated delta JSON, since the final response is authoritative and the accumulated deltas can be inconsistent.
read and glob tool calls sometimes start without enough information to build command display actions (e.g. read called without a filePath, or glob before the pattern/path are known). Previously, these would render with empty titles in the TUI and never get corrected.
Fix: