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
This commit is contained in:
tongzhou wang
2026-07-25 16:12:42 +00:00
committed by copyberry
parent af7f6f4d34
commit 5c36e869c1
+6 -3
View File
@@ -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,