Skip to content

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

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

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
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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