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

Đang mở Phù hợp với người mới
#64,479 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@akhil9tiet đang làm issue này rồi.

Từ ngày 28/11/2026.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
cli, networking

Hướng nghiên cứu

Bắt đầu với parser guard trong codex-rs/codex-api/src/sse/responses.rs và hợp đồng định tuyến trong cùng lượt trong codex-rs/core/src/client.rs. Mở rộng fixture trong codex-rs/core/tests/suite/turn_state.rs để sự kiện metadata sử dụng codex.response.metadata, sau đó chạy test đó. Hoàn tất khi token được phát lại trong cùng lượt, được đặt lại ở lượt tiếp theo và hành vi hiện có của response.metadata vẫn vượt qua.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Rust
Star
136k
Fork
21.6k
Merge trung bình
1 phút
Pull request đã merge (30 ngày)
999

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của openai/codex

Tất cả issue của openai/codex

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.