Aliceonly's trace on #1418: sub2api answered 502 "Upstream HTTP/2 stream
failed", then Codex account A answered 200, sent only the frames before a
reply, and failed server_is_overloaded 37s in. Five candidates after it
were never asked, and Codex ended the turn. The stream had been let
through (h.passing), so holdWriter.failed() was false and neither the next
candidate nor a replan was tried.
Two ways a frames-only stream went through:
- streamEvent's default was eventContent: any event it didn't know (and an
item of a type said() didn't know) counted as the reply begun. Now only
the events of each protocol that carry text, reasoning, a call or a
reply's end (replyEvent) count; anything else is eventLead, held as a
ping is. An unknown item counts only when it is a call or a tool's
(web_search_call, server_tool_use, mcp_*). A stream that ends well is
still released whole, so this can only delay, never drop, a reply.
- a reply under a Content-Type that says neither JSON nor a stream, once
the agent had a stream's headers, went straight through when its first
bytes were SSE (sseStart -> pass()). It is now held as a stream from
there and read event by event.
Which event Codex's backend actually sent isn't in the trace; the test
uses a keepalive, response.rate_limits.updated and an unknown item type.
Run: go test ./internal/gateway -count=1, green (428s).
TestFramesThenOverloadedGoesToTheNext (new: 502, then 200 frames + unknown
events + server_is_overloaded, then a third member) and
TestStreamEventUnknownOnlyFrames (new) fail on the old fallback.go: the
overloaded stream reaches the agent and c is never asked.
TestHeldUnsureStreamPasses/KeptAlive now expect the stream held until its
first word, and TestHeldUnsureStreamFailsHeld (new) a failure among held
frames; all fail on the old code. Not tried against the real ChatGPT
backend.