Skip to content

fix: reset grace-retry counters on mistake limit and fix manual retry userMessageWasRemoved#12296

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/empty-response-retry-and-mistake-limit-reset-12284
Draft

fix: reset grace-retry counters on mistake limit and fix manual retry userMessageWasRemoved#12296
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/empty-response-retry-and-mistake-limit-reset-12284

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 Bot commented May 8, 2026

Related GitHub Issue

Closes: #12284

Description

This PR attempts to address Issue #12284, specifically the related error reported by @PlanBernhard where the model hits the mistake_limit_reached threshold after empty API responses. Feedback and guidance are welcome.

Two bugs found:

  1. Missing userMessageWasRemoved flag in manual retry path (same fix as PR fix: add missing userMessageWasRemoved flag in manual retry for empty API responses #12291): When the user clicks "Retry" after an empty API response, the userMessageWasRemoved flag was not set on the retry stack item. This caused the retry to skip re-adding the user message to conversation history, leading to cascading empty responses that could ultimately trigger the mistake limit.

  2. Grace-retry counters not reset on mistake limit dialog: When consecutiveMistakeCount is reset to 0 after the user provides guidance via the mistake limit dialog, consecutiveNoToolUseCount and consecutiveNoAssistantMessagesCount were NOT reset. This meant the very next no-tool-use or empty response would immediately show an error and re-increment consecutiveMistakeCount (since the counters were still >= 2), creating a frustrating loop where the user keeps hitting the mistake limit despite providing guidance.

Changes:

  • Added userMessageWasRemoved: true to the manual retry stack.push() in the empty API response handler
  • Added resets for consecutiveNoToolUseCount and consecutiveNoAssistantMessagesCount alongside the existing consecutiveMistakeCount = 0 in the mistake limit handler
  • Added 3 new tests covering the counter reset behavior

Test Procedure

  • All existing grace-retry tests pass (14/14, including 3 new): cd src && npx vitest run core/task/__tests__/grace-retry-errors.spec.ts
  • All lint and type checks pass (verified via pre-push hooks)
  • The counter reset fix can be verified by inspecting the code: after the mistake_limit_reached dialog, all three counters are now reset together, giving the model a fresh grace-retry period

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue.
  • Scope: Changes are focused on the linked issue.
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New tests added covering counter reset behavior.
  • Documentation Impact: No documentation updates needed.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

This PR overlaps with PR #12291 on the userMessageWasRemoved fix. The additional value here is the grace-retry counter reset fix, which addresses the cascading failure loop reported by @PlanBernhard. If PR #12291 is merged first, the userMessageWasRemoved change in this PR can be dropped, but the counter reset fix remains independently valuable.

Interactively review PR in Roo Code Cloud

… userMessageWasRemoved

- Add missing userMessageWasRemoved flag to manual retry path for empty
  API responses (same fix as PR #12291). Without this, the user message
  is not re-added to conversation history on retry, causing cascading
  empty responses.

- Reset consecutiveNoToolUseCount and consecutiveNoAssistantMessagesCount
  when the mistake_limit_reached dialog is shown and consecutiveMistakeCount
  is reset. Without this, these counters remain elevated after the user
  provides guidance, causing the very next no-tool-use or empty response
  to immediately show an error and re-increment consecutiveMistakeCount,
  creating a frustrating loop.

- Add tests for counter reset behavior on mistake limit.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Unexpected API Response: The language model did not provide any assistant messages. This may indicate an issue with the API or the model's output.

1 participant