-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix duplicate tool blocks causing 'tool has already been used' error #9275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
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
- Add protocol detection in Task.ts to prevent merging parsed tool blocks with native tool blocks when using XML protocol - Fix approval feedback flow in presentAssistantMessage.ts to add feedback directly without calling pushToolResult - Resolves bug introduced in PR #9159 where tool blocks were duplicated, causing false 'already used' errors
Contributor
Review completed - no issues found. The fix correctly addresses the duplicate tool blocks issue by:
The implementation is well-structured and uses appropriate type guards consistent with codebase patterns. Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
mrubens
approved these changes
Nov 15, 2025
mini2s
added a commit
to zgsm-ai/costrict
that referenced
this pull request
Nov 17, 2025
Problem
After PR #9159 added native tool support, users experienced a false 'tool has already been used in this message' error on every turn when using XML protocol (default).
Root Cause
In
Task.ts, when the stream completes, the code was unconditionally merging parsed content blocks with native tool blocks:For XML protocol,
parsedBlocksalready contained the tool_use blocks parsed from XML text. The merge duplicated them - adding the same tool twice. When the first tool executed and setdidAlreadyUseTool = true, the duplicate was incorrectly blocked.Solution
Added protocol detection to only merge native tool blocks when using native protocol:
Also fixed the approval feedback flow to avoid prematurely setting the
didAlreadyUseToolflag.Testing
Important
Fixes duplicate tool blocks in
Task.tsby adding protocol detection to handle merging correctly based on protocol type.Task.tsby adding protocol detection.didAlreadyUseToolflag setting.Task.tsto check protocol type before merging tool blocks.This description was created by
for 287bb97. You can customize this summary. It will automatically update as commits are pushed.