diff --git a/codex-rs/core/src/responses_metadata.rs b/codex-rs/core/src/responses_metadata.rs index 698e5a0ca2..89421a9739 100644 --- a/codex-rs/core/src/responses_metadata.rs +++ b/codex-rs/core/src/responses_metadata.rs @@ -38,6 +38,7 @@ pub(crate) const COMPACTION_KEY: &str = "compaction"; pub(crate) const LEGACY_CODE_MODE_TOOL_NAMES_KEY: &str = "code_mode_tool_names"; pub(crate) const TOOL_NAMESPACES_INFO_KEY: &str = "tool_namespaces_info"; pub(crate) const TURN_STARTED_AT_UNIX_MS_KEY: &str = "turn_started_at_unix_ms"; +pub(crate) const HISTORY_INGEST_REQUESTED_KEY: &str = "history_ingest_requested"; pub(crate) const FORKED_FROM_THREAD_ID_KEY: &str = "forked_from_thread_id"; pub(crate) const FORKED_FROM_ORDINAL_EXCLUSIVE_KEY: &str = "forked_from_ordinal_exclusive"; @@ -75,6 +76,7 @@ const RESERVED_METADATA_KEYS: &[&str] = &[ LEGACY_CODE_MODE_TOOL_NAMES_KEY, TOOL_NAMESPACES_INFO_KEY, TURN_STARTED_AT_UNIX_MS_KEY, + HISTORY_INGEST_REQUESTED_KEY, FORKED_FROM_THREAD_ID_KEY, FORKED_FROM_ORDINAL_EXCLUSIVE_KEY, PARENT_THREAD_ID_KEY, @@ -242,6 +244,7 @@ pub struct CodexResponsesMetadata { pub(crate) workspaces: BTreeMap, pub(crate) tool_namespaces_info: Option, pub(crate) turn_started_at_unix_ms: Option, + pub(crate) history_ingest_requested: Option, pub(crate) extra: BTreeMap, } @@ -280,6 +283,7 @@ impl CodexResponsesMetadata { workspaces: BTreeMap::new(), tool_namespaces_info: None, turn_started_at_unix_ms: None, + history_ingest_requested: None, extra: BTreeMap::new(), } } @@ -407,6 +411,7 @@ impl CodexResponsesMetadata { workspaces: non_empty_workspaces(&self.workspaces), tool_namespaces_info: self.tool_namespaces_info.as_ref(), turn_started_at_unix_ms: self.turn_started_at_unix_ms, + history_ingest_requested: self.history_ingest_requested, compaction, // Extra metadata enriches the Codex turn metadata blob, not literal top-level // Responses client_metadata. Product metadata is validated while loading config; @@ -552,6 +557,8 @@ struct CodexTurnMetadataPayload<'a> { #[serde(default, skip_serializing_if = "Option::is_none")] turn_started_at_unix_ms: Option, #[serde(default, skip_serializing_if = "Option::is_none")] + history_ingest_requested: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] compaction: Option, #[serde(flatten)] extra: &'a BTreeMap, diff --git a/codex-rs/core/src/session/session.rs b/codex-rs/core/src/session/session.rs index 011afa2d0f..273b48470c 100644 --- a/codex-rs/core/src/session/session.rs +++ b/codex-rs/core/src/session/session.rs @@ -612,6 +612,12 @@ impl Session { CodexResponsesMetadata { window_number: Some(window_number), context_window_id: Some(context_window_id), + history_ingest_requested: turn_context + .config + .token_budget + .as_ref() + .is_some_and(|config| config.use_history_notes_extension) + .then_some(true), forked_from_ordinal_exclusive: self .forked_from_ordinal_exclusive .filter(|_| responses_metadata.forked_from_thread_id.is_some()),