fix: retry wrapped responses server errors#22022
Open
tossp wants to merge 2 commits intoanomalyco:devfrom
Open
fix: retry wrapped responses server errors#22022tossp wants to merge 2 commits intoanomalyco:devfrom
tossp wants to merge 2 commits intoanomalyco:devfrom
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #21979
Type of change
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_errorvalidation 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.4path 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.tsbun test test/session/retry.test.ts test/session/llm.test.tsbun typecheckThe new regression test reproduces the wrapped Responses
server_errorpayload, 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