From 5c36e869c1a7bdc5ec4c1325d02e60dfbadcc9b8 Mon Sep 17 00:00:00 2001 From: tongzhou wang Date: Sat, 25 Jul 2026 16:07:34 +0000 Subject: [PATCH] Bound Code Mode metadata compatibility headers (#35364) ## Why The Code Mode tool-name mapping is unbounded and can make HTTP and WebSocket headers grow without limit. ## What changed Omit `code_mode_tool_names` from the direct `x-codex-turn-metadata` compatibility header while retaining it in the canonical `client_metadata["x-codex-turn-metadata"]` payload. GitOrigin-RevId: 494a30b6846e32ab44eb79b08dfec63360f563a7 --- codex-rs/core/src/responses_metadata.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/codex-rs/core/src/responses_metadata.rs b/codex-rs/core/src/responses_metadata.rs index 6724516a15..794b50930e 100644 --- a/codex-rs/core/src/responses_metadata.rs +++ b/codex-rs/core/src/responses_metadata.rs @@ -248,10 +248,13 @@ impl CodexResponsesMetadata { pub(crate) fn compatibility_headers(&self) -> ApiHeaderMap { let mut headers = ApiHeaderMap::new(); insert_header(&mut headers, X_CODEX_WINDOW_ID_HEADER, &self.window_id); - // Direct x-codex-turn-metadata is compatibility output. New per-request consumers should - // prefer client_metadata["x-codex-turn-metadata"], which is rendered from this same object. + // Direct x-codex-turn-metadata is compatibility output. Keep the unbounded Code Mode + // mapping in client_metadata only so HTTP and WebSocket headers remain bounded. if self.has_turn_metadata() - && let Some(turn_metadata_json) = self.turn_metadata_json() + && let Ok(turn_metadata_json) = to_ascii_json_string(&CodexTurnMetadataPayload { + code_mode_tool_names: None, + ..self.turn_metadata_payload() + }) { insert_header( &mut headers,