Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Nov 17, 2025

Problem

When attempt_completion was called and the user clicked 'Yes' to mark the task complete, pushToolResult("") was adding an empty tool_result to userMessageContent. This triggered Task.ts:2609 to create a NEW API request with the empty result, causing the task to continue indefinitely with additional tool calls.

Root Cause

  • pushToolResult("") adds content to userMessageContent[] via presentAssistantMessage.ts:323-327
  • Task.ts:2609 checks if (this.userMessageContent.length > 0) and pushes to stack
  • This creates a new API request even though the task should end

The Fix

Remove pushToolResult("") when task completes successfully. The tool_result is now only sent when the user provides feedback, which is the correct behavior for native protocol.

Before (buggy)

  1. attempt_completion called
  2. User clicks Yes
  3. pushToolResult("") triggers new API request
  4. Model continues with infinite loop

After (fixed)

  1. attempt_completion called
  2. User clicks Yes
  3. NO pushToolResult("") - task stops (correct)

When user provides feedback

  1. attempt_completion called
  2. User provides feedback
  3. pushToolResult(feedback) - new API request with feedback (correct)

Additional Fix

This also fixes a related 400 error where duplicate tool results could occur when users sent messages after task completion.

Context

The bug was introduced in commit 5e6e601 (native tool support PR) where the empty tool_result was meant as a 'stop signal' but was being treated as real content.

Testing

All existing tests pass (317 test files, 4117 tests)


Important

Fixes infinite loop in AttemptCompletionTool.ts by removing unnecessary pushToolResult("") call on task completion.

  • Behavior:
    • Removes pushToolResult("") in AttemptCompletionTool.ts when task completes successfully to prevent infinite loop.
    • Ensures pushToolResult(feedback) is only called when user provides feedback.
  • Bug Fixes:
    • Fixes infinite loop caused by unnecessary API request in AttemptCompletionTool.ts.
    • Resolves 400 error from duplicate tool results after task completion.
  • Context:
    • Bug introduced in commit 5e6e601 where empty tool_result was misused as a stop signal.

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

When attempt_completion was called and the user clicked 'Yes' to mark the task complete, pushToolResult("") was adding an empty tool_result to userMessageContent. This triggered Task.ts:2609 to create a NEW API request with the empty result, causing the task to continue indefinitely with additional tool calls.

Root Cause:
- pushToolResult("") adds content to userMessageContent[] via presentAssistantMessage.ts:323-327
- Task.ts:2609 checks 'if (this.userMessageContent.length > 0)' and pushes to stack
- This creates a new API request even though the task should end

The Fix:
Remove pushToolResult("") when task completes successfully. The tool_result is now only sent when the user provides feedback, which is the correct behavior for native protocol.

Before (buggy):
1. attempt_completion called
2. User clicks Yes
3. pushToolResult("") -> triggers new API request
4. Model continues -> infinite loop

After (fixed):
1. attempt_completion called
2. User clicks Yes
3. NO pushToolResult("") -> task stops (correct)

When user provides feedback:
1. attempt_completion called
2. User provides feedback
3. pushToolResult(feedback) -> new API request with feedback (correct)

This also fixes a related 400 error where duplicate tool results could occur when users sent messages after task completion.

The bug was introduced in commit 5e6e601 (native tool support PR) where the empty tool_result was meant as a 'stop signal' but was being treated as real content.
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Nov 17, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Nov 17, 2025
@dosubot dosubot bot added the bug Something isn't working label Nov 17, 2025
@roomote
Copy link
Contributor

roomote bot commented Nov 17, 2025

Rooviewer Clock   See task on Roo Cloud

Review completed. No issues found.

This commit removes an outdated comment from the code - a purely cosmetic cleanup following the actual bug fix from the previous commit.

Previous reviews

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

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 17, 2025
@daniel-lxs daniel-lxs merged commit e742511 into main Nov 17, 2025
13 checks passed
@daniel-lxs daniel-lxs deleted the fix/attempt-completion-loop branch November 17, 2025 23:24
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Nov 17, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Nov 17, 2025
mini2s added a commit to zgsm-ai/costrict that referenced this pull request Nov 18, 2025