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
bug(agents): OpenAI WS late-map buffering gates on key existence not phase validity — unphased commentary can leak to UI #61477
After #59643 merged, the WS late-map buffering in src/agents/openai-ws-stream.ts can permanently misattribute early text deltas as "no phase."
Root cause
Text deltas are buffered until outputItemPhaseById has the item id. But the map is populated on the firstresponse.output_item.added/done seen for that item, and stores undefined if event.item.phase is missing/invalid at that moment:
outputItemPhaseById.set(event.item.id,itemPhase);// may be undefined
...
if(outputItemPhaseById.has(event.item_id))emitBufferedTextDelta(...)
The gate is presence of the map key, not validity of the phase. Once an item event arrives with undefined phase, all subsequent text for that item emits immediately as unphased — even if a later output_item.done event would carry the correct phase.
Impact
If a provider emits output_item.added before phase is populated (or emits contradictory metadata between added/done), commentary text can leak as unphased visible content. This is the "malformed/missing phase metadata" edge case that the buffering was meant to protect against.
Gate on outputItemPhaseById.get(event.item_id) !== undefined (phase is known and valid), not just outputItemPhaseById.has(event.item_id) (any item event arrived).
Severity
P2 — requires a specific provider timing quirk to trigger, but when it does, it defeats the buffering protection entirely.
Part of the post-#59643 adversarial review family. See #61474 for the full list. This is the WS streaming race condition variant — affects the OpenAI Responses API late item-mapping path specifically.
changed the title [-]bug(agents): WS late-map buffering gates on item key existence, not phase validity[/-][+]bug(agents): OpenAI WS late-map buffering gates on key existence not phase validity — unphased commentary can leak to UI[/+]on Apr 5, 2026
Activity
100yenadmin commentedon Apr 5, 2026
Part of the post-#59643 adversarial review family. See #61474 for the full list. This is the WS streaming race condition variant — affects the OpenAI Responses API late item-mapping path specifically.
[-]bug(agents): WS late-map buffering gates on item key existence, not phase validity[/-][+]bug(agents): OpenAI WS late-map buffering gates on key existence not phase validity — unphased commentary can leak to UI[/+]fix(agents): keep phaseless OpenAI WS text buffered until phase resol…
fix(agents): keep phaseless OpenAI WS text buffered until phase resol…
fix(agents): keep phaseless OpenAI WS text buffered until phase resol…
fix(agents): keep phaseless OpenAI WS text buffered until phase resol…
fix(agents): keep phaseless OpenAI WS text buffered until phase resol…
fix(agents): keep phaseless OpenAI WS text buffered until phase resol…