Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 18, 2026

Summary

This PR attempts to address Issue #10814, where Roo Code gets stuck in an endless loop repeating the same tool call while ignoring user messages.

Problem

When the model gets stuck in a repetitive loop (repeating the same tool call or not using tools), user messages sent during this time are queued but never processed. The model keeps receiving the same error feedback without any way for the user to intervene and redirect it.

Solution

Added queue message processing at two critical points in the task loop:

1. In Task.ts - No Tool Use Detection (line ~3540)

When consecutiveNoToolUseCount >= 2, the fix now checks for queued user messages and injects them as feedback to break the loop:

if (!this.messageQueueService.isEmpty()) {
    const queuedMessage = this.messageQueueService.dequeueMessage()
    if (queuedMessage) {
        await this.say("user_feedback", queuedMessage.text, queuedMessage.images)
        this.userMessageContent.push({
            type: "text",
            text: formatResponse.tooManyMistakes(queuedMessage.text),
        })
        // Reset mistake counter since user provided guidance
        this.consecutiveMistakeCount = 0
        this.consecutiveNoToolUseCount = 0
    }
}

2. In presentAssistantMessage.ts - Tool Repetition Detection (line ~826)

When ToolRepetitionDetector detects identical consecutive tool calls, the fix now checks for queued messages before asking the user for feedback:

if (!cline.messageQueueService.isEmpty()) {
    const queuedMessage = cline.messageQueueService.dequeueMessage()
    if (queuedMessage) {
        feedbackText = queuedMessage.text
        feedbackImages = queuedMessage.images
        await cline.say("user_feedback", feedbackText, feedbackImages)
    }
}

How It Helps

  1. With auto-approve enabled: User messages that were previously queued and ignored will now be processed when error conditions occur, allowing the user to break out of loops.

  2. Resets counters: When user guidance is received, mistake counters are reset, giving the model a fresh start with the user-provided direction.

  3. Shows feedback in UI: The user's message is displayed in the chat so they know their intervention was received.

Testing

  • All existing tests pass (142 tests)
  • Type checks pass
  • Lint checks pass

Feedback Welcome

This is my attempt at addressing the issue. Please review and provide feedback!

Fixes #10814


Important

Fixes issue where queued user messages were ignored during endless loops by processing them at critical points in Task.ts and presentAssistantMessage.ts.

  • Behavior:
    • In Task.ts, when consecutiveNoToolUseCount >= 2, checks for queued user messages and injects them as feedback to break the loop.
    • In presentAssistantMessage.ts, when ToolRepetitionDetector detects identical consecutive tool calls, checks for queued messages before asking the user for feedback.
  • Counters:
    • Resets consecutiveMistakeCount and consecutiveNoToolUseCount when user feedback is processed.
  • UI Feedback:
    • Displays user feedback in chat to confirm intervention was received.

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

…10814)

When the model gets stuck in a repetitive loop (repeating the same tool call
or not using tools), user messages sent during this time are queued but never
processed because the model keeps receiving the same error feedback.

This fix adds queue processing at two critical points:

1. In Task.ts when consecutiveNoToolUseCount >= 2: Check for queued messages
   and inject them as user feedback to break the loop.

2. In presentAssistantMessage.ts when tool repetition is detected: Check for
   queued messages before asking the user, allowing previously queued messages
   to provide the intervention needed.

Both fixes reset the mistake counters when user guidance is received, giving
the model a fresh start with the user-provided direction.

Fixes #10814
@roomote
Copy link
Contributor Author

roomote bot commented Jan 18, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The changes correctly address the issue where queued user messages were ignored during endless loops. The fix adds queue message processing at two critical intervention points:

  1. Task.ts: When the model fails to use tools repeatedly (consecutiveNoToolUseCount >= 2), queued messages are now checked and processed as user feedback.
  2. presentAssistantMessage.ts: When the ToolRepetitionDetector blocks execution due to identical consecutive tool calls, queued messages are checked before prompting the user.

Both implementations properly reset mistake counters when user guidance is received, follow existing code patterns, and handle edge cases appropriately.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] Roo stuck in endless loop, not responding to any instructions

2 participants