mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-08 22:21:23 +00:00
fix: add maximum retry limit for empty assistant responses
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.
This commit is contained in:
parent
3c05cae722
commit
f1cc359b0a
1 changed files with 9 additions and 1 deletions
|
|
@ -137,6 +137,7 @@ const MAX_EXPONENTIAL_BACKOFF_SECONDS = 600 // 10 minutes
|
|||
const DEFAULT_USAGE_COLLECTION_TIMEOUT_MS = 5000 // 5 seconds
|
||||
const FORCED_CONTEXT_REDUCTION_PERCENT = 75 // Keep 75% of context (remove 25%) on context window errors
|
||||
const MAX_CONTEXT_WINDOW_RETRIES = 3 // Maximum retries for context window errors
|
||||
const MAX_EMPTY_RESPONSE_RETRIES = 3 // Maximum retries for empty assistant response errors
|
||||
|
||||
export interface TaskOptions extends CreateTaskOptions {
|
||||
provider: ClineProvider
|
||||
|
|
@ -3307,7 +3308,14 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
|
||||
// Check if we should auto-retry or prompt the user
|
||||
// Reuse the state variable from above
|
||||
if (state?.autoApprovalEnabled) {
|
||||
// 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) {
|
||||
// Auto-retry with backoff - don't persist failure message when retrying
|
||||
await this.backoffAndAnnounce(
|
||||
currentItem.retryAttempt ?? 0,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue