Skip to content

Fix Codex routing: restore SSE Content-Type and send probes as the account identity - #193

Merged
HTExplicit merged 2 commits into
mainfrom
fix/codex-sse-content-type
Sep 23, 2026
Merged

HTExplicit merged 2 commits into
mainfrom
fix/codex-sse-content-type

Conversation

@HTExplicit

@HTExplicit HTExplicit commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Problem

  1. Missing Content-Type (root cause of the v0.2.7-codexrip.2 acceptance failure). Since 2026-09-23 the ChatGPT edge omits Content-Type on /backend-api/codex/responses SSE replies. A fixed production-egress diagnostic (9 real requests, accounts 16376/16380/16379, astra/sol/luna, Lite and legacy bodies, account and harvest proxies) returned HTTP 200 with no content-type header, while the body was a normal SSE stream ending in response.completed whose response.model equals the requested model; __oailb/__cflb were issued on every reply. readCodexRoutingCompletion and the qualified-route observer only use the SSE parser when the header says text/event-stream; otherwise they json.Unmarshal the whole stream, fail, and record routing_incomplete — exactly the acceptance result (HTTP 200, 780-char turn-state, routing_incomplete). With fail_closed=true this keeps OAuth accounts out of the four gated models. Client tool-name mapping and image streaming key on the same header.
  2. Probe identity. buildCodexRoutingProbe never set originator/User-Agent, and enforceCodexIdentityHeadersForAccountContext only aligns an originator that is already present, so every acquisition/verification left as Go-http-client/1.1 on a ChatGPT OAuth token. Once observations work, these probes repeat per enrolled account and model.

Change

  • repository: after decompression, relabel a 200 reply to a POST chatgpt.com/backend-api/codex/responses request that asked for text/event-stream as text/event-stream when the upstream sent no type (Do, DoWithTLS, connection lease). Compact (JSON) and every other endpoint are untouched.
  • service: the routing completion reader also recognises an untyped body by its SSE framing (covers the pinned-trust acquisition client, which bypasses the repository).
  • service: routing probes set originator, user-agent and version from the account's resolved outbound identity — the same triple the routing scope profile hashes.
  • .downstream/gpt6-routing-and-prompts.md: one line recording the upstream behaviour.

Tests

Minimal, one per defect: TestRestoreCodexEventStreamContentType (stream relabelled, compact untouched), one assertion in TestCodexRoutingCompletionRequiresOriginalModelAndDelimitedTerminal (untyped stream verifies), and TestCodexRoutingProbeSpeaksAsAccountIdentity. All pass locally; full verification is left to the required CI checks.

🤖 Generated with Claude Code

Codex and others added 2 commits September 23, 2026 18:11
Since 2026-09-23 the ChatGPT edge no longer sends Content-Type on
/backend-api/codex/responses streams (9/9 production-egress requests:
no content-type header, body still SSE ending in response.completed with
the requested model). readCodexRoutingCompletion and the qualified-route
observer only parse SSE when the header says text/event-stream, so every
cold acquisition, verification and business observation ended as
routing_incomplete and fail_closed locked OAuth accounts out of the gated
GPT-6 models. Tool-name mapping and image streaming key on the same header.

- Relabel a 200 reply to a POST chatgpt.com/backend-api/codex/responses
  request that asked for text/event-stream as text/event-stream when the
  upstream sent no type (Do, DoWithTLS and the connection lease).
- Let the routing completion reader recognise an untyped body by its SSE
  framing, covering the pinned-trust acquisition client as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
buildCodexRoutingProbe never set originator or User-Agent, and
enforceCodexIdentityHeadersForAccountContext only aligns an originator
that is already present, so every acquisition and verification left as
Go-http-client/1.1 on a ChatGPT OAuth token. With routing observations
working again those probes repeat per enrolled account and model.

Set originator, user-agent and version from the account's resolved
outbound identity, the same triple the routing scope profile hashes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HTExplicit HTExplicit changed the title Restore SSE Content-Type for ChatGPT Codex streams Fix Codex routing: restore SSE Content-Type and send probes as the account identity Sep 23, 2026
@HTExplicit
HTExplicit merged commit 21ea4d2 into main Sep 23, 2026
16 checks passed
@HTExplicit
HTExplicit deleted the fix/codex-sse-content-type branch September 23, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant