mirror of
https://github.com/openai/codex.git
synced 2026-11-12 21:20:34 +00:00
Include code-mode tool names in Responses Lite metadata (#35271)
## What changed - Add `code_mode_tool_names` to Responses Lite turn metadata, mapping each normalized code-mode identifier to its structured `ToolName`. - Reserve the metadata key against client overrides and omit it from metadata exposed to external MCP servers. - Keep non-Lite requests and the legacy top-level client metadata unchanged. ## Testing - Cover HTTP and WebSocket Responses Lite requests, including switching from a non-Lite model. - Verify reserved-key handling and external MCP metadata filtering. GitOrigin-RevId: b678afba13d57a91e26f5895aa37238fbb4cb276
This commit is contained in:
@@ -7,6 +7,7 @@ use codex_analytics::CompactionReason;
|
||||
use codex_analytics::CompactionStrategy;
|
||||
use codex_analytics::CompactionTrigger;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::ToolName;
|
||||
use codex_protocol::protocol::InternalSessionSource;
|
||||
use codex_protocol::protocol::SessionSource;
|
||||
use codex_protocol::protocol::SubAgentSource;
|
||||
@@ -30,6 +31,7 @@ pub(crate) const TURN_ID_KEY: &str = "turn_id";
|
||||
pub(crate) const WINDOW_ID_KEY: &str = "window_id";
|
||||
pub(crate) const REQUEST_KIND_KEY: &str = "request_kind";
|
||||
pub(crate) const COMPACTION_KEY: &str = "compaction";
|
||||
pub(crate) const CODE_MODE_TOOL_NAMES_KEY: &str = "code_mode_tool_names";
|
||||
pub(crate) const TURN_STARTED_AT_UNIX_MS_KEY: &str = "turn_started_at_unix_ms";
|
||||
|
||||
pub(crate) const FORKED_FROM_THREAD_ID_KEY: &str = "forked_from_thread_id";
|
||||
@@ -54,6 +56,7 @@ const RESERVED_METADATA_KEYS: &[&str] = &[
|
||||
X_OPENAI_SUBAGENT_HEADER,
|
||||
REQUEST_KIND_KEY,
|
||||
COMPACTION_KEY,
|
||||
CODE_MODE_TOOL_NAMES_KEY,
|
||||
TURN_STARTED_AT_UNIX_MS_KEY,
|
||||
FORKED_FROM_THREAD_ID_KEY,
|
||||
PARENT_THREAD_ID_KEY,
|
||||
@@ -165,6 +168,7 @@ pub struct CodexResponsesMetadata {
|
||||
pub(crate) thread_source: Option<ThreadSource>,
|
||||
pub(crate) sandbox: Option<String>,
|
||||
pub(crate) workspaces: BTreeMap<String, TurnMetadataWorkspace>,
|
||||
pub(crate) code_mode_tool_names: Option<BTreeMap<String, ToolName>>,
|
||||
pub(crate) turn_started_at_unix_ms: Option<i64>,
|
||||
pub(crate) extra: BTreeMap<String, String>,
|
||||
}
|
||||
@@ -190,6 +194,7 @@ impl CodexResponsesMetadata {
|
||||
thread_source: None,
|
||||
sandbox: None,
|
||||
workspaces: BTreeMap::new(),
|
||||
code_mode_tool_names: None,
|
||||
turn_started_at_unix_ms: None,
|
||||
extra: BTreeMap::new(),
|
||||
}
|
||||
@@ -292,6 +297,7 @@ impl CodexResponsesMetadata {
|
||||
thread_source: self.thread_source.as_ref(),
|
||||
sandbox: self.sandbox.as_deref(),
|
||||
workspaces: non_empty_workspaces(&self.workspaces),
|
||||
code_mode_tool_names: self.code_mode_tool_names.as_ref(),
|
||||
turn_started_at_unix_ms: self.turn_started_at_unix_ms,
|
||||
compaction,
|
||||
// responsesapi_client_metadata enriches the Codex turn metadata blob, not literal
|
||||
@@ -382,6 +388,8 @@ struct CodexTurnMetadataPayload<'a> {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
workspaces: Option<&'a BTreeMap<String, TurnMetadataWorkspace>>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
code_mode_tool_names: Option<&'a BTreeMap<String, ToolName>>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
turn_started_at_unix_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
compaction: Option<CompactionTurnMetadata>,
|
||||
|
||||
Reference in New Issue
Block a user