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

Abierto Apto para principiantes
#64,479 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@akhil9tiet ya está trabajando en esto.

Desde el 28/11/2026.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
88/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust
Área
cli, networking

Línea de trabajo

Comienza con el guard del parser en codex-rs/codex-api/src/sse/responses.rs y el contrato de enrutamiento del mismo turno en codex-rs/core/src/client.rs. Amplía el fixture en codex-rs/core/tests/suite/turn_state.rs para que el evento de metadatos use codex.response.metadata, y luego ejecuta esa prueba. Estará terminado cuando el token se reproduzca dentro del mismo turno, se reinicie en el siguiente turno y el comportamiento existente de response.metadata siga pasando.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
Rust
Estrellas
136k
Forks
21.6k
Merge medio
1 min
PR fusionados (30 d)
999

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de openai/codex

Todos los issues de openai/codex

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.