tensornull's Codex turn on an Anthropic-compatible proxy (baseAPI
anthropic, claude-opus-5-5) ended as response.completed after 21s with
no output: the route had status 200, no usage, no served model, no
ttft. Codex took it as its turn's end (last_agent_message null) and
didn't ask again. No usage and no served model mean the proxy never sent
a message_start Claude would have (it counts the prompt and names the
model), yet the stream said it ended (message_stop or a stop_reason), so
320af9858's replyEnds read it as whole and errEndedShort didn't apply.
Now a reply from an Anthropic or Responses upstream (repliesCounted) that
said nothing (no text, call, search or image) and counted no token at all
(uncounted) is the empty reply #667 already handles for Gemini: asked
again in place, then failed with "an empty reply (the model answered
nothing; try again)", which Codex retries. Same in streamTranslated and
the unstreamed translate path, for Responses, Messages and Chat clients.
Claude's own empty end_turn (after a tool's result) counts its prompt and
still completes, as does a Responses reply with usage and no output.
Not changed: a reply passed through in its own protocol (Codex asking a
Responses provider, Claude Code an Anthropic one) isn't read for this;
the passthrough has no empty-reply rule at all, Gemini's included.
Verified:
- New stream_uncounted_test.go. TestUncountedEmptyReplyFails (message_stop
only; pings then message_stop; message_start with no usage then a
stop_reason; zero usage), TestUncountedResponsesReplyFails and
TestUncountedEmptyReplyFailsEveryClient (Chat streamed, Responses and
Chat unstreamed) all FAIL on the old code ("ended response.completed
\"completed\", want response.failed", "status 200, want the empty
reply's failure") and pass with the change. TestCountedEmptyReplyStillCompletes
and the #1933 tests (TestWellFormedStreamsStillComplete, TestMalformed*)
pass.
- The full go test -tags nogui ./internal/gateway run failed only
TestCodexHeadersReachKeyedRelay and TestStandaloneNativeAccounts, whose
fake Codex backends answered response.completed with output [] and no
usage, which the real backend never sends; their fakes now count
tokens, and both pass. Run in a sandbox HOME with pinned
caches; gofmt -l; go vet ./internal/gateway for darwin,
GOOS=linux -tags nogui and GOOS=windows; GOOS=linux go build -tags
nogui and GOOS=windows go build.
- Not tried: the reporter's proxy or its real bytes (the report has none);
the fixtures are the shapes its route record allows. Not run: the full
go test ./... (only internal/gateway changed).