Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Jan 7, 2026

Problem

When a user approves a tool execution AND provides feedback text, askApproval in presentAssistantMessage.ts was pushing the feedback as a separate tool_result. This created duplicate tool_result blocks with the same tool_use_id because 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.ts that 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 pushToolResult is called:

  1. Added approvalFeedback storage variable to hold feedback until tool completes
  2. Modified pushToolResult to merge stored feedback into the tool's actual result content
  3. Updated askApproval to store feedback instead of pushing it as a separate tool_result
  4. This applies to both MCP tools and regular tools, and both native and XML protocols

Changes

  • src/core/assistant-message/presentAssistantMessage.ts - root fix for both MCP and regular tools
  • src/core/task/validateToolResultIds.ts - updated comments (deduplication kept as safety net)

Testing

  • All existing tests pass (5153 tests)
  • The deduplication safety net in validateAndFixToolResultIds.ts remains as defense-in-depth

Closes ROO-410


Important

Fixes duplicate tool_result issue by merging approval feedback into tool results in presentAssistantMessage.ts.

  • Behavior:
    • presentAssistantMessage.ts: Merges approval feedback into tool results instead of creating duplicate tool_result blocks.
    • Applies to both MCP tools and regular tools, and both native and XML protocols.
  • Implementation:
    • Adds approvalFeedback variable to store feedback until tool completion.
    • Modifies pushToolResult to merge stored feedback into tool results.
    • Updates askApproval to store feedback instead of pushing it as a separate tool_result.
  • Validation:
    • validateToolResultIds.ts: Keeps deduplication as a safety net for unknown edge cases.
  • Testing:
    • All existing tests pass (5153 tests).
    • Deduplication remains as defense-in-depth.

This description was created by Ellipsis for e4e67e2. You can customize this summary. It will automatically update as commits are pushed.

…icate (ROO-410)

When users approve tool execution with feedback text, the feedback was being
pushed as a separate tool_result before the actual tool executed and pushed
its own result. This created duplicate tool_results with the same tool_use_id,
violating the Anthropic API protocol (GitHub #10465).

Changes:
- Add approvalFeedback storage to hold feedback until tool completes
- Modify pushToolResult to merge stored feedback into the tool's actual result
- Update askApproval to store feedback instead of pushing as separate result
- Apply fix to both MCP tools and regular tools, native and XML protocols
- Update validateToolResultIds comments to clarify deduplication is now safety net
@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners January 7, 2026 16:59
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Jan 7, 2026
@roomote
Copy link
Contributor

roomote bot commented Jan 7, 2026

Rooviewer Clock   See task on Roo Cloud

Reviewed the changes to fix duplicate tool_result blocks. Found one issue that needs attention:

  • XML protocol path doesn't handle approval feedback images (approvalFeedback.images is ignored while native protocol handles it correctly)

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jan 7, 2026
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Jan 8, 2026
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jan 8, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 9, 2026
@mrubens mrubens merged commit 7b771a2 into main Jan 9, 2026
27 checks passed
@mrubens mrubens deleted the feature/roo-410-fix-duplicate-tool_results-when-approval-feedback-is branch January 9, 2026 15:01
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jan 9, 2026
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants