Skip to content

fix: retry OpenAI overload errors#25886

Open
johnwaldo wants to merge 2 commits intoanomalyco:devfrom
johnwaldo:fix/provider-overload-retry-status
Open

fix: retry OpenAI overload errors#25886
johnwaldo wants to merge 2 commits intoanomalyco:devfrom
johnwaldo:fix/provider-overload-retry-status

Conversation

@johnwaldo
Copy link
Copy Markdown

@johnwaldo johnwaldo commented May 5, 2026

Issue for this PR

Closes #25884

Type of change

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

What does this PR do?

OpenAI-compatible streams can return server_is_overloaded / service_unavailable_error as a stream error event.

This PR maps that stream error to the existing retryable API error path, and keeps the generic retry classifier aware of the same nested provider code/type when it arrives as plain JSON or an API response body.

This overlaps with #25728. I opened this from the OpenAI side before seeing that PR; happy to close this one if maintainers prefer the Codex-focused PR.

How did you verify your code works?

Local automated tests were not run because bun is not installed in this environment. I added focused regression tests in:

  • packages/opencode/test/session/retry.test.ts
  • packages/opencode/test/session/message-v2.test.ts

Screenshots / recordings

Not applicable; no UI changes.

Checklist

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

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

The following comment was made by an LLM, it may be inaccurate:

I found several potentially related PRs. Let me filter out the current PR (#25886) and highlight the relevant ones:

Potential Duplicates/Related PRs:

  1. PR fix(session): retry Codex server_is_overloaded stream errors #25728 - fix(session): retry Codex server_is_overloaded stream errors

    • Directly related: This PR handles server_is_overloaded retry logic for Codex (similar to the OpenAI overload error handling in the current PR)
  2. PR fix: retry streamed provider error envelopes #23841 - fix: retry streamed provider error envelopes

    • Related: Addresses retryable stream errors from providers, which overlaps with the current PR's goal of handling streamed OpenAI overload payloads
  3. PR fix(opencode): extract statusCode from error variants for 5xx retry #19204 - fix(opencode): extract statusCode from error variants for 5xx retry

    • Related: Handles 5xx status code extraction for retries, which aligns with the current PR's handling of 503 API responses

These PRs are worth reviewing to ensure there's no overlap or conflicting approaches to retry handling across different providers.

@johnwaldo
Copy link
Copy Markdown
Author

johnwaldo commented May 5, 2026

Thanks for the automated guidance. I updated the issue and PR to match the repo templates and removed the generated footer/long-form wording.

I also checked the related work and saw #25728 covers the same server_is_overloaded stream shape from the Codex side. I pushed one small adjustment here so this branch also routes the stream error through parseStreamError, not just the later retry classifier.

If maintainers prefer #25728, I can close this PR as a duplicate. Otherwise this one is now the same narrow bug fix from the OpenAI-compatible stream angle.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

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

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.

OpenAI server_is_overloaded stream errors are not retried

1 participant