You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sawTextOutputInCurrentResponse is handler state, so an overlapping second stream resets the first stream's text-output flag #2412
src/api/providers/openai-native.ts:63 declares sawTextOutputInCurrentResponse on the handler, not per request. It records whether the current response produced text and drives the done-only-text fallback at the end of a stream.
Census at a4a629acf2 (git grep -n -F sawTextOutputInCurrentResponse):
17 sites in openai-native.ts: declared at :63, reset only at :236 inside handleResponsesApiMessage (declared :221); the other 15 sit inside processEvent (declared :1427), with the three reads at :1461, :1607 and :1630.
0 references in src/api/providers/__tests__/openai-native.spec.ts at head: the flag has no test.
the merge-base provider blob d6ab76a0f89825f3410f66fca4da5e435132794c carries the same 17 sites, with the stream loops additionally gated on the shared this.abortController at base :480 and base :721. PR feat(api): abort signal support for openai-native #1291 made abort state request-local; it changed neither the count nor the reset point.
the sibling handler src/api/providers/openai-codex.ts carries the same field with 29 sites, so the shape is not specific to this provider.
The mechanism
createMessage can be called twice on one handler before the first stream finishes — overlapping requests sharing a handler is the shape PR #1291 already exercises for bodies at openai-native.spec.ts:1882. Both generators run handleResponsesApiMessage, whose first message event resets the shared field at :236. A second request's reset therefore changes the first request's fallback outcome: a stream that produced text can end as "no text output", or the reverse, depending on interleaving.
Every write sits in the generator chain the consumer drives (:1423-:1638) — there is no detached provider write — so the interleaving that makes it observable is consumer-side, which is why no provider-local test names it today.
What a fix looks like
Thread it as request state along the request-local route PR #1291 already opened: handleStreamResponse (:921) takes a request-local controller, so the same route can carry a per-request record into processEvent (:1427) and out to the fallback decision. Plainly stated, the fix is the 15-site threading through handleStreamResponse and processEvent, plus the task keeping its drain pointed at that request's state, plus rows pinning two overlapping streams with different text-output outcomes — of which the head has none.
#1291 is a 4-file compat unit about abort-signal ownership and provider error identity. Threading request state through the event processor is a production change of a different class, the class predates the PR (merge-base evidence above: d6ab76a0f89825f3410f66fca4da5e435132794c carries the same 17 sites), and it deserves its own rows and its own mutation preflight. Raised in #1291 review thread 4506478035; the reviewer offered to file it at 4509634587.
Activity