Skip to content

fix: retry wrapped responses server errors#22022

Open
tossp wants to merge 2 commits intoanomalyco:devfrom
tossp:fix/wrapped-responses-retry
Open

fix: retry wrapped responses server errors#22022
tossp wants to merge 2 commits intoanomalyco:devfrom
tossp:fix/wrapped-responses-retry

Conversation

@tossp
Copy link
Copy Markdown

@tossp tossp commented Apr 11, 2026

Issue for this PR

Closes #21979

Type of change

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

What does this PR do?

This fixes a case where a wrapped Responses error payload like { "error": { "type": "server_error" } } is thrown by the upstream SDK as a validation error before a terminal event is emitted.

Before this change, OpenCode treated that SDK error as an unknown error, which leaked the raw validation failure into the TUI and stopped the normal retry path.

This change remaps that specific wrapped server_error validation failure into a retryable session API error inside OpenCode's own error boundary. That keeps the raw validation message out of the session error surface and lets the existing retry flow recover normally.

It also adds a regression test for the openai / gpt-5.4 path and extends the test LLM server so the test can send raw Responses chunks without changing @ai-sdk/openai.

How did you verify your code works?

I verified it locally with:

  • bun test test/session/processor-effect.test.ts
  • bun test test/session/retry.test.ts test/session/llm.test.ts
  • bun typecheck

The new regression test reproduces the wrapped Responses server_error payload, verifies the retry state is emitted, verifies the model call is retried, and verifies no terminal session error is stored after recovery.

Screenshots / recordings

Not applicable. This is not a UI 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. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Apr 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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.

Wrapped stream error chunks bypass retry and can leave parent sessions waiting forever

1 participant