fix(provider): recover stalled model streams - #40010
Open
dcadenas wants to merge 3 commits into
Open
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found two potentially related PRs:
These PRs appear to be addressing overlapping concerns about streaming robustness and timeouts in provider responses. You may want to review them to ensure PR #40010 doesn't duplicate existing fixes or to coordinate any related changes. |
dcadenas
marked this pull request as ready for review
August 1, 2026 07:08
This was referenced Aug 1, 2026
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 #37580
Type of change
What does this PR do?
A model endpoint can return response headers and then stop producing body data. OpenCode currently waits forever in that state, which can leave foreground Task parents stranded behind a stalled child.
This adds a provider-neutral stream-idle watchdog with a safe default. It starts with a 15-minute deadline, learns from successful streams per provider and transport, and keeps the adaptive deadline between 15 and 30 minutes. An explicit
chunkTimeoutremains a fixed override, whilefalse, zero, or a negative value disables the watchdog.The watchdog recognizes either an SSE response header or
stream: truein the request. This matters because the direct ChatGPT Codex endpoint was observed returning a streaming response withoutContent-Type. Non-streaming requests remain unchanged. When a response omitsContent-Type, the watchdog activates only when the JSON request explicitly setsstream: true, covering the observed response without applying adaptive timing to unrelated fetches.A timeout becomes a typed retryable provider error and uses the existing retry and status flow. This does not change Task orchestration, durable session records, retry policy, or UI behavior.
Related work
chunkTimeoutto every response body. This change instead provides a zero-config adaptive default and limits wrapping to requests identified as streaming, including responses withoutContent-Type.chunkTimeout.How did you verify your code works?
bun test --timeout 30000 test/provider/header-timeout.test.ts test/provider/stream-liveness.test.ts test/session/processor-effect.test.ts test/session/retry.test.ts— 72 passedbun typecheckinpackages/corebun typecheckinpackages/opencodeContent-Typecase is covered directly without proxy header normalization.Screenshots / recordings
Not applicable; there are no UI changes.
Checklist