fix(opencode): gate provider 400 rate limit retries - #40239
Open
maximkr wants to merge 6 commits into
Open
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
maximkr
marked this pull request as ready for review
August 3, 2026 07:58
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.
Issue for this PR
Fixes #40241
Type of change
What does this PR do?
When an organization uses a one-minute LLM limit window, some providers report the exhausted window as a non-standard HTTP 400 response with a JSON
detailcontainingrate limit exceeded. OpenCode previously treated that response as terminal and stopped session processing.This PR adds the provider-local opt-in
provider.<id>.options.retry400RateLimit. When enabled, the existing retry flow handles only matching HTTP 400 rate-limit responses. Generic HTTP 400 responses remain non-retryable, and the option is not passed through as an SDK request option.The implementation threads the setting through
SessionProcessorandMessageV2.fromErrorintoProviderError.parseAPICallError, with unit and processor integration tests plus design documentation.How did you verify your code works?
bun test test/session/retry.test.ts test/session/processor-effect.test.ts --timeout 30000frompackages/opencode— 52 passed, 0 failed.bun typecheckfrompackages/opencode— passed.git diff --check— passed.TS1128error inpackages/enterprise/src/custom-elements.d.ts.Screenshots / recordings
Not applicable; this is a server/session error-handling change.
Checklist