fix: add retry limits and context recovery hint for error retries (#12087)#12090
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
fix: add retry limits and context recovery hint for error retries (#12087)#12090roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
…2087) - Add MAX_STREAM_RETRIES (5) limit for both mid-stream and first-chunk error auto-retries. Previously there was no cap, allowing indefinite retry loops with only exponential backoff. - When mid-stream error retries are exhausted, present the error to the user via api_req_failed ask instead of continuing silently. - When first-chunk error retries are exhausted with autoApprovalEnabled, fall through to the manual retry prompt instead of continuing. - Add a context recovery hint to the user content on mid-stream error retries. This helps weaker models re-orient after a provider error instead of hallucinating about previously completed tasks. - Add tests for retry limit enforcement and context recovery hint.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #12087
Description
This PR attempts to address Issue #12087 where provider errors during auto-retry cause the model to lose track of the current task and hallucinate about previously completed work.
Root cause analysis: After a provider error + auto-retry, the
apiConversationHistoryis correctly preserved. However, weaker models (e.g., glm-5 via OpenAI Compatible) can get confused by the conversation structure after an error discontinuity, especially when the current task prompt is embedded several messages back as atool_resultonattempt_completion. The model latches onto the strong "Task Completed" signal from the prior task instead of the new request. Auto-approved operations (file read/write) then allow this hallucination to cascade.Changes:
Add
MAX_STREAM_RETRIES(5) limit: Both mid-stream and first-chunk error auto-retries now have a cap. Previously there was no limit -- only exponential backoff up to 10 minutes. When the limit is reached, the error is surfaced to the user via the manual retry prompt.Add context recovery hint on mid-stream error retries: When retrying after a mid-stream error, a brief instruction is prepended to the user content reminding the model to continue with the most recent request and not repeat completed work. This helps weaker models re-orient after the error discontinuity.
Graceful fallthrough for first-chunk errors: When
autoApprovalEnabledis true and max retries are exhausted, the code falls through to the manual retry prompt instead of continuing indefinitely.Test Procedure
src/core/task/__tests__/error-retry-limits.spec.tswith 9 tests covering:Task.spec.ts(38 passed, 4 skipped -- pre-existing skips)cd src && npx vitest run core/task/__tests__/error-retry-limits.spec.tsPre-Submission Checklist
Documentation Updates
Additional Notes
Feedback and guidance are welcome. The context recovery hint text can be tuned if needed -- the current wording is designed to be clear and directive without being too verbose.
Interactively review PR in Roo Code Cloud