Skip to content

fix(opencode): retry nested OpenAI errors - #142

Merged
MagMueller merged 1 commit into
mainfrom
nested-server-error
Aug 4, 2026
Merged

fix(opencode): retry nested OpenAI errors#142
MagMueller merged 1 commit into
mainfrom
nested-server-error

Conversation

@MagMueller

@MagMueller MagMueller commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

No linked issue.

Type of change

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

What does this PR do?

OpenAI Responses streams can report a transient failure as a nested response.failed event with the error at response.error. The existing parser only recognized top-level error events, so nested server_error and server_is_overloaded events became terminal unknown errors.

This keeps the parser change narrow: those two nested transient codes become retryable APIError values and flow through the existing SessionRetry policy. Other nested response.failed codes retain their current terminal behavior.

Follow-up risk intentionally left out of scope: SessionRetry caps each backoff wait, but generic retryable API errors do not currently have a total-attempt cap.

How did you verify your code works?

  • bun test test/session/retry.test.ts --timeout 30000: 37 passed
  • bun typecheck from packages/opencode: passed
  • pre-push filtered workspace typecheck: 16/16 packages passed

Added regression coverage for both nested transient codes and for a nested non-retryable code remaining terminal.

Screenshots / recordings

Not applicable; no UI change.

Checklist

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

Summary by cubic

Makes nested OpenAI stream server errors retryable so transient failures don’t abort sessions. Detects server_error and server_is_overloaded inside response.failed events and routes them through the existing retry policy.

  • Bug Fixes
    • Updated opencode parser to handle nested response.failed errors: server_error and server_is_overloaded now map to retryable API errors; other nested codes stay terminal.
    • Added regression tests for both retryable and non-retryable nested cases.

Written for commit 05f9985. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@MagMueller
MagMueller merged commit fe1a7b2 into main Aug 4, 2026
3 checks passed
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.

1 participant