fix: merge approval feedback into tool result instead of pushing duplicate (ROO-410) #10519
+77
−12
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.
Problem
When a user approves a tool execution AND provides feedback text,
askApprovalinpresentAssistantMessage.tswas pushing the feedback as a separatetool_result. This created duplicatetool_resultblocks with the sametool_use_idbecause the actual tool also pushes its result when it executes.This is a protocol violation for the Anthropic API and was documented as GitHub #10465. A workaround existed in
validateAndFixToolResultIds.tsthat deduplicated results AFTER they were created, but the root cause was never addressed.Solution
Instead of pushing approval feedback as a separate tool_result, the feedback is now stored and merged into the actual tool's result when
pushToolResultis called:approvalFeedbackstorage variable to hold feedback until tool completespushToolResultto merge stored feedback into the tool's actual result contentaskApprovalto store feedback instead of pushing it as a separate tool_resultChanges
src/core/assistant-message/presentAssistantMessage.ts- root fix for both MCP and regular toolssrc/core/task/validateToolResultIds.ts- updated comments (deduplication kept as safety net)Testing
validateAndFixToolResultIds.tsremains as defense-in-depthCloses ROO-410
Important
Fixes duplicate
tool_resultissue by merging approval feedback into tool results inpresentAssistantMessage.ts.presentAssistantMessage.ts: Merges approval feedback into tool results instead of creating duplicatetool_resultblocks.approvalFeedbackvariable to store feedback until tool completion.pushToolResultto merge stored feedback into tool results.askApprovalto store feedback instead of pushing it as a separatetool_result.validateToolResultIds.ts: Keeps deduplication as a safety net for unknown edge cases.This description was created by
for e4e67e2. You can customize this summary. It will automatically update as commits are pushed.