fix(session): retry top-level stream request timeouts - #40268
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Related PRs:
These are related PRs addressing similar stream reliability concerns, but #39413 is the most directly relevant since your PR explicitly complements it. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
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:
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. |
Issue for this PR
Closes #39221
Type of change
What does this PR do?
Some OpenAI Responses-compatible providers return HTTP 200 and then emit this
SSE error event:
{"type":"error","sequence_number":0,"code":"request_timeout","message":"stream error: stream disconnected before completion"}parseStreamError()only readbody.error.code, so the top-level timeout wasnot classified as retryable and the turn stopped. This change recognizes the
top-level
request_timeoutcode and uses the existing retry policy.This complements #39413, which handles an HTTP 408 response status. This PR
handles the separate HTTP 200 plus SSE error response shape.
How did you verify your code works?
bun test test/session/retry.test.ts(34 pass)bun typecheckbunx prettier --check packages/opencode/src/provider/error.ts packages/opencode/test/session/retry.test.tsMessageV2.fromError()throughSessionRetry.retryable()and verifies the parsed error is retryable.Screenshots / recordings
Not a UI change.
Checklist