You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: add stream retry cap and context recovery hint for provider errors (#12087)
- Add MAX_STREAM_RETRIES (5) to cap first-chunk and mid-stream error retries,
preventing indefinite retry loops when auto-approval is enabled
- Add context recovery hint prepended to user content on retry attempts,
helping weaker models re-orient to the current task instead of
hallucinating about previously completed tasks
- When max retries are exceeded, present the error to the user for manual
retry instead of continuing to auto-retry indefinitely
- Update last user message in API history on retry with recovery hint and
refreshed environment details
text: "[CONTEXT RECOVERY NOTE: The previous API request failed due to a provider error and was automatically retried. Please focus on the user's most recent request below and continue from where you left off. Do not repeat or re-announce previously completed tasks.]",
// note that this api_req_failed ask is unique in that we only present this option if the api hasn't streamed any content yet (ie it fails on the first chunk due), as it would allow them to hit a retry button. However if the api failed mid-stream, it could be in any arbitrary state where some tools may have executed, so that error is handled differently and requires cancelling the task entirely.
4329
4375
if(autoApprovalEnabled){
4376
+
// Check if we've exceeded the maximum number of stream retries
4377
+
if(retryAttempt>=MAX_STREAM_RETRIES){
4378
+
console.error(
4379
+
`[Task#${this.taskId}.${this.instanceId}] Max first-chunk retries (${MAX_STREAM_RETRIES}) exceeded, presenting error to user`,
0 commit comments