WebSocket client ignores x-codex-turn-state in codex.response.metadata

Aperta Adatta ai principianti
#64,479 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@akhil9tiet ci sta già lavorando.

Dal 28/11/2026.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
cli, networking

Direzione di ricerca

Inizia dalla guard del parser in codex-rs/codex-api/src/sse/responses.rs e dal contratto di routing dello stesso turno in codex-rs/core/src/client.rs. Estendi il fixture in codex-rs/core/tests/suite/turn_state.rs in modo che l’evento di metadati usi codex.response.metadata, quindi esegui quel test. È completo quando il token viene riproposto nello stesso turno, viene reimpostato al turno successivo e il comportamento esistente di response.metadata continua a superare il test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug CLI connectivity
What version of Codex CLI is running?

Reproduced with codex-cli 0.172.0 on Linux using a synthetic WebSocket provider on loopback. The same parser guard is present on main at 065e18b04021008e2e7d504db8dc50275f589f73. The fixture uses no subscription or API credentials.

What issue are you seeing?

A codex.response.metadata event can supply an x-codex-turn-state header. ResponsesStreamEvent::turn_state() only reads headers on response.metadata, so the WebSocket client discards the token and omits it from client_metadata on the same-turn tool continuation. It replays the same synthetic token when only the event type changes to response.metadata.

What steps can reproduce the bug?

Use a loopback Responses WebSocket fixture with no turn-state header on the upgrade response. Send this event before the first generation's synthetic tool call, then let the tool call complete and inspect the next response.create on the same socket.

{"type":"codex.response.metadata","headers":{"x-codex-turn-state":"synthetic-turn-state"}}

Repeat in a fresh session with the event type changed to response.metadata. Both runs completed over one socket. There were two generation requests per run after excluding prewarm.

Incoming metadata event Turn state on the outgoing tool continuation
response.metadata synthetic-turn-state
codex.response.metadata Absent

The in-tree websocket_turn_state_persists_within_turn_and_resets_after test provides an equivalent regression fixture. Add a variant that replaces the first turn's response.metadata event with codex.response.metadata and keeps the existing replay and next-turn reset assertions.

What is the expected behavior?

Accept turn state from the WebSocket metadata event and replay the first token on subsequent requests within the same turn. Preserve the existing behavior for response.metadata and clear state at the next turn boundary.

Additional information
  • Current parser guard
  • Same-turn routing contract
  • Related to #30536, which tracks the missing header on the WebSocket upgrade. This repro targets the parser when the token arrives after the upgrade. It makes no claim about the cause of an intermittent cache miss.
Lingua principale
Rust
Stelle
136k
Fork
21.6k
Merge medio
1m
PR unite (30g)
999

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di openai/codex

Tutte le issue di openai/codex

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.