From 98f8a3311ba7cac785e570713127e9127af4043a Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 23 Nov 2026 22:26:20 +0000 Subject: [PATCH] Exclude sequence numbers from Responses stream deltas by default (#63479) ## Why Codex does not use sequence numbers on text or custom tool input deltas. ## What changed Add `delta.sequence_number` to the default `x-codex-exclude-stream-fields` header for Responses requests over HTTP and WebSocket. Explicit provider header values still take precedence. ## Testing Update the WebSocket handshake and HTTP output-token replay tests to expect the new default. GitOrigin-RevId: d16ecb10f9188ba9cca4504e1b68e32832fb931a --- codex-rs/core/src/client.rs | 3 ++- codex-rs/core/tests/suite/client_websockets.rs | 2 +- codex-rs/core/tests/suite/output_token_replay.rs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) mode change 100755 => 100644 codex-rs/core/tests/suite/client_websockets.rs diff --git a/codex-rs/core/src/client.rs b/codex-rs/core/src/client.rs index 2f91855b13..1845e9d5ed 100644 --- a/codex-rs/core/src/client.rs +++ b/codex-rs/core/src/client.rs @@ -2984,13 +2984,14 @@ fn build_responses_headers( /// Apply Responses stream defaults after resolving provider headers so explicit exclusions win. fn with_default_stream_exclusions(mut provider: ApiProvider) -> ApiProvider { + // Text and custom tool input deltas don't need sequence numbers. // Reasoning replay only needs the ciphertext on the finished item. // Negotiate separately so older servers still recognize x-codex-exclude. provider .headers .entry("x-codex-exclude-stream-fields") .or_insert(HeaderValue::from_static( - "reasoning.added.encrypted_content", + "delta.sequence_number,reasoning.added.encrypted_content", )); provider } diff --git a/codex-rs/core/tests/suite/client_websockets.rs b/codex-rs/core/tests/suite/client_websockets.rs old mode 100755 new mode 100644 index 59e253f7ca..46a675c915 --- a/codex-rs/core/tests/suite/client_websockets.rs +++ b/codex-rs/core/tests/suite/client_websockets.rs @@ -308,7 +308,7 @@ async fn responses_websocket_streams_request() { ); assert_eq!( handshake.header("x-codex-exclude-stream-fields").as_deref(), - Some("reasoning.added.encrypted_content") + Some("delta.sequence_number,reasoning.added.encrypted_content") ); assert_eq!( handshake.header("session-id"), diff --git a/codex-rs/core/tests/suite/output_token_replay.rs b/codex-rs/core/tests/suite/output_token_replay.rs index 818706efe0..3d95e8c13e 100644 --- a/codex-rs/core/tests/suite/output_token_replay.rs +++ b/codex-rs/core/tests/suite/output_token_replay.rs @@ -122,7 +122,7 @@ async fn output_token_replay_respects_provider_and_preserves_history( requests[0] .header("x-codex-exclude-stream-fields") .as_deref(), - Some("reasoning.added.encrypted_content") + Some("delta.sequence_number,reasoning.added.encrypted_content") ); let expected_include = if enabled && openai_provider { json!(["reasoning.encrypted_content", "output.encrypted_content"])