Skip to content

fix(opencode): gate provider 400 rate limit retries - #40239

Open
maximkr wants to merge 6 commits into
anomalyco:devfrom
maximkr:provider-rate-limit-retry
Open

fix(opencode): gate provider 400 rate limit retries#40239
maximkr wants to merge 6 commits into
anomalyco:devfrom
maximkr:provider-rate-limit-retry

Conversation

@maximkr

@maximkr maximkr commented Aug 3, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #40241

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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 detail containing rate 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 SessionProcessor and MessageV2.fromError into ProviderError.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 30000 from packages/opencode — 52 passed, 0 failed.
  • bun typecheck from packages/opencode — passed.
  • git diff --check — passed.
  • The repository-wide pre-push typecheck is currently blocked by an unrelated existing TS1128 error in packages/enterprise/src/custom-elements.d.ts.

Screenshots / recordings

Not applicable; this is a server/session error-handling change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@maximkr
maximkr marked this pull request as ready for review August 3, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Provider-specific HTTP 400 rate-limit responses stop processing

1 participant