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
Context overflow 400 is retried because the error message contains "500000" (substring match of "500") #52464
The session retry layer's RETRYABLE_MESSAGE_PATTERNS in packages/opencode/src/session/retry.ts matches status codes as raw substrings:
/429|500|502|503|504|524/i
Any error message that merely contains those digits inside a larger number is misclassified as retryable. For example, a deterministic 400 whose message includes a large token count:
"The input (523659 tokens) is longer than the model's context length (500000 tokens)" → matches "500"
"... 4290 requests ..." → matches "429"
"... id 503123 not found ..." → matches "503"
When such an error reaches retryable() as a plain APIError (i.e. when it was not classified as ContextOverflowError upstream), the policy retries a request that can never succeed, up to 5 times with exponential backoff, before surfacing the error to the user.
This is a distinct failure mode from the context-overflow classification in packages/llm/src/provider-error.ts (isContextOverflow): the classifier handles the known phrasings, but any 4xx error carrying one of these numbers in its text — from a gateway, proxy, or a provider phrasing not in the pattern list — still falls through to the retry layer and hits the substring match.
Steps to reproduce
Unit-level (deterministic):
An APIError is constructed from a 4xx response whose message contains a large number, e.g. ... context length (500000 tokens)
Activity
github-actions commentedon Oct 2, 2026
Thanks for updating the issue with reproduction steps and system details!
rekram1-node commentedon Oct 2, 2026
This is not an issue on opencode v2:
https://opencode.ai/v2/docs
rekram1-node commentedon Oct 5, 2026
recommend updating to v2.