fix(streaming): resume truncated Responses streams mid-stream - #14639
Merged
diegosouzapw merged 1 commit intoSep 24, 2026
Merged
diegosouzapw merged 1 commit into
diegosouzapw merged 1 commit into
Conversation
maxmad64bis
force-pushed
the
fix/responses-midstream-continuation
branch
from
September 23, 2026 13:12
8b8bd4f to
0c4724f
Compare
maxmad64bis
marked this pull request as ready for review
September 23, 2026 13:22
Mid-stream continuation only understood chat-completions SSE behind a translated chat request: on the Responses upstream path the scan stayed shut, the continuation body required messages, and a short complete turn had no recognized terminal marker. The recovery layer now scans Responses events (text and reasoning deltas, function-call signals gated on function_call items, completed/failed/incomplete terminals), replays received text as an assistant input item, and stitches the suffix plus a minimal response.completed snapshot in the upstream envelope so the downstream translator still decides stop versus tool_calls. Tool-call, overlap, and reasoning-only guards are unchanged.
maxmad64bis
force-pushed
the
fix/responses-midstream-continuation
branch
from
September 23, 2026 13:52
0c4724f to
766ffdb
Compare
3 of 5 tasks
5 tasks done
Owner
|
Substantial and well-tested extension — the fold/sink refactor of the scanner is a clean |
2 of 5 tasks
diegosouzapw
merged commit Sep 24, 2026
1aea068
into
diegosouzapw:release/v3.8.51
9 of 16 checks passed
5 tasks done
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.
Summary
Mid-stream continuation only understands chat-completions events behind a translated chat request: on the Responses upstream path the scan stays shut, the continuation body requires messages, and a short complete turn has no recognized terminal marker, so an enabled setting silently does nothing there. The recovery layer now scans Responses events (text and reasoning deltas, function-call signals gated on function_call items, completed/failed/incomplete terminals), replays received text as an assistant input item, and stitches the suffix plus a minimal response.completed snapshot in the upstream envelope so the downstream translator still decides stop versus tool_calls. Tool-call, overlap, and reasoning-only guards are unchanged; chat behavior is untouched.
Related Issues
Related to #4147 (origin: chat-only mid-stream continuation this PR extends to Responses)
Related to #11151 (prior: reasoning-only resume whose text-only guard this PR reuses)
Related to #11902 (orthogonal: client-side retryable signal; this PR is the server-side resume)
Validation
npm run lintrev-list HEAD..upstream/release/v3.8.51= 0, unit 24/24 + neighbors 88/88 and touched-file ESLint clean rerun after push @0c4724fd)Tests Added Or Updated
tests/unit/stream-continuation-responses.test.ts(new, 24 tests: Responses scan, terminal markers, continuation bodies, short-complete never resumed, cut-resume stitching, tool-call OFF/ON, translator traversal stop/tool_calls/idempotent; RED 7/17 on the base, GREEN 24/24 here)stream-continuation,stream-continuation-wiring,stream-recovery-toolcall,stream-recovery,stream-recovery-trace-logging,chatcore-stream-recovery-log-wiring— 88/88 passCoverage Notes
N/A — no coverage gate moved; new branches in
streamRecovery.tsare covered by the new test (scan, continuation body, stitching per format).Reviewer Notes
response.completedis never re-requested (flush, no retry);failed/incompleteend the turn without resume.766ffdb):Fast Quality Gatesflagged one owned-file regression (streamRecovery.tscomplexity 5→8, cognitive 3→4, new-code mode), fixed by splitting into smaller helpers with identical semantics (amended, lease0c4724fd→766ffdb); local gate nowcomplexityNewCode=0/cognitiveComplexityNewCode=-1, unit 24/24 + neighbors 88/88 replayed. Remaining reds qualified as inherited (failures cite files outside this PR, unchanged since the merge-base, base-red issue 🔴 Release branch not green: release/v3.8.51 #14547, normalized failure lists identical to same-base feat(sse): distinguish content-stall from transport failure in stream error codes #14582):API Route Typecheck4 errors (auggie.tsTS2769/TS18047,projectCombo.tsTS2459/TS2724, no PR file cited,comm -23empty vs feat(sse): distinguish content-stall from transport failure in stream error codes #14582);typecheck:coresingle error incliproxyAccountHealth.tsidentical on the clean base checkout (out of scope); fullnpm run lintred on the base (🔴 Release branch not green: release/v3.8.51 #14547);check:docs-allDEEP_HEALTH_CHECK_ENABLEDpresent on the untouched base (health/route.ts:46) outside the PR, existing flag of the resumed test kept as is.