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. 👍 |
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