-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix: add maximum retry limit for empty assistant responses #10206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This fix addresses Issue #10106 where the system enters infinite retry loops when API providers (Roo Cloud, OpenRouter, Requesty) return empty assistant responses while auto-approval is enabled. Changes: - Add MAX_EMPTY_RESPONSE_RETRIES constant (3 retries) - Add retry limit check before auto-retry logic - When limit is reached, fall back to user prompt instead of continuing to auto-retry indefinitely This is a centralized fix in Task.ts that benefits all providers, addressing the systemic nature of the issue rather than implementing provider-specific safeguards.
Review completed. Found 1 issue that needs to be addressed before merging.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| // Check if we've exceeded maximum retries for empty responses | ||
| const emptyResponseRetryCount = currentItem.retryAttempt ?? 0 | ||
| if (emptyResponseRetryCount >= MAX_EMPTY_RESPONSE_RETRIES) { | ||
| console.warn( | ||
| `[Task#${this.taskId}.${this.instanceId}] Empty response retry limit reached (${emptyResponseRetryCount}/${MAX_EMPTY_RESPONSE_RETRIES}). Falling back to user prompt.`, | ||
| ) | ||
| // Fall through to manual retry prompt below | ||
| } else if (state?.autoApprovalEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "fall through" comment is misleading. Due to the if-else-if-else structure, when emptyResponseRetryCount >= MAX_EMPTY_RESPONSE_RETRIES is true, the code executes only the console.warn, then skips both the else if and else branches entirely, falling through to return false at line 3390. This means the user is NOT prompted when the retry limit is reached - the task silently returns false.
To actually fall through to the user prompt, restructure the condition:
| // Check if we've exceeded maximum retries for empty responses | |
| const emptyResponseRetryCount = currentItem.retryAttempt ?? 0 | |
| if (emptyResponseRetryCount >= MAX_EMPTY_RESPONSE_RETRIES) { | |
| console.warn( | |
| `[Task#${this.taskId}.${this.instanceId}] Empty response retry limit reached (${emptyResponseRetryCount}/${MAX_EMPTY_RESPONSE_RETRIES}). Falling back to user prompt.`, | |
| ) | |
| // Fall through to manual retry prompt below | |
| } else if (state?.autoApprovalEnabled) { | |
| // Check if we've exceeded maximum retries for empty responses | |
| const emptyResponseRetryCount = currentItem.retryAttempt ?? 0 | |
| if (state?.autoApprovalEnabled && emptyResponseRetryCount < MAX_EMPTY_RESPONSE_RETRIES) { |
This way, when the retry limit is reached OR auto-approval is disabled, the code enters the else branch which prompts the user.
Fix it with Roo Code or mention @roomote and request a fix.
This PR attempts to address Issue #10106. Feedback and guidance are welcome.
Problem
When API providers (Roo Cloud, OpenRouter, Requesty) return empty assistant responses while auto-approval is enabled, the system enters infinite retry loops with exponential backoff. This consumes tokens/credits indefinitely without user intervention.
As noted by @uaktags in the issue, this is a systemic issue affecting multiple providers, not just a single provider.
Solution
This PR adds a centralized fix in
Task.tsthat benefits all providers:MAX_EMPTY_RESPONSE_RETRIES = 3- limits retries for empty assistant response errorsThis follows the same pattern as the existing
MAX_CONTEXT_WINDOW_RETRIESlimit.Changes
src/core/task/Task.ts:MAX_EMPTY_RESPONSE_RETRIESconstant (line 140)Testing
Related