Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Comment on lines +3311 to +3318
Copy link
Contributor Author

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:

Suggested change
// 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.

// Auto-retry with backoff - don't persist failure message when retrying
await this.backoffAndAnnounce(
currentItem.retryAttempt ?? 0,
Expand Down
Loading