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
{{ message }}
Repository navigation
Exponential backoff caps at ~25 days on headers-present retry path #20126
When the upstream API returns an error with HTTP response headers but without a retry-after header, the SessionRetry logic in src/session/retry.ts uses an exponential backoff capped at 2,147,483,647 ms (~24.86 days / ~3 weeks). This makes the session appear permanently stuck after ~22 failed attempts.
In contrast, the no-headers code path correctly caps at 30,000 ms (30 seconds).
How to reproduce
Have the upstream proxy return repeated 502 Bad Gateway responses with standard HTTP headers but no retry-after header
Let the retry loop run past attempt ~22
The UI will display "retrying in ~3 weeks" and the session becomes effectively frozen
In my case, this was a corporate proxy returning 502s. By attempt #45, the backoff had long since hit the ceiling.
Observed behavior
The error message reads:
Bad Gateway: Failed to proxy request: Post "https://..."
(click to expand) [retrying in ~3 weeks attempt #45]
The cap() function uses RETRY_MAX_DELAY (the ~25 day value) when response headers are present, even if there's no retry-after header. The exponential formula 2000 * 2^(attempt-1) exceeds this cap at attempt 22, so from attempt 22 onward every retry waits ~25 days.
There is also no maximum attempt count -- the retry loop continues indefinitely.
Suggested fix
Cap RETRY_MAX_DELAY at something reasonable (e.g., 60 seconds or 120 seconds)
Consider adding a maximum attempt count, or at minimum, resetting the backoff after some threshold
When no retry-after header is present, use the same 30-second cap regardless of whether other headers exist
Workaround
Press Escape twice to interrupt the retry fiber, then re-send the message. This resets the attempt counter for that turn without losing session context.
Activity
github-actions commentedon Mar 30, 2026
This issue might be a duplicate of an existing issue. Please check:
retry.tswhen response headers are present, no cap applied unlike the no-headers path, sessions becoming stuck for hours. The analysis and proposed fixes are nearly identical.github-actions commentedon Jul 4, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.