diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 9487a9b650..1d43b2c1f6 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -759,20 +759,6 @@ impl Session { .flatten() } - async fn get_or_build_turn_metadata_header(&self, cwd: &Path) -> Option { - if let Some(cached) = { - let state = self.state.lock().await; - state.cached_turn_metadata_header(cwd) - } { - return cached; - } - - let header = Self::build_turn_metadata_header(cwd).await; - let mut state = self.state.lock().await; - state.set_turn_metadata_header_cache(cwd, header.clone()); - header - } - #[allow(clippy::too_many_arguments)] async fn new( mut session_configuration: SessionConfiguration, @@ -1309,9 +1295,8 @@ impl Session { if let Some(final_schema) = final_output_json_schema { turn_context.final_output_json_schema = final_schema; } - turn_context.turn_metadata_header = self - .get_or_build_turn_metadata_header(turn_context.cwd.as_path()) - .await; + turn_context.turn_metadata_header = + Self::build_turn_metadata_header(turn_context.cwd.as_path()).await; Arc::new(turn_context) } @@ -3267,9 +3252,8 @@ async fn spawn_review_thread( parent_turn_context.client.transport_manager(), ); - let turn_metadata_header = sess - .get_or_build_turn_metadata_header(parent_turn_context.cwd.as_path()) - .await; + let turn_metadata_header = + Session::build_turn_metadata_header(parent_turn_context.cwd.as_path()).await; let review_turn_context = TurnContext { sub_id: sub_id.to_string(), client, diff --git a/codex-rs/core/src/state/session.rs b/codex-rs/core/src/state/session.rs index 479f44f562..deee0d0c7c 100644 --- a/codex-rs/core/src/state/session.rs +++ b/codex-rs/core/src/state/session.rs @@ -3,7 +3,6 @@ use codex_protocol::models::ResponseItem; use std::collections::HashMap; use std::collections::HashSet; -use std::path::Path; use crate::codex::SessionConfiguration; use crate::context_manager::ContextManager; @@ -20,7 +19,6 @@ pub(crate) struct SessionState { pub(crate) server_reasoning_included: bool, pub(crate) dependency_env: HashMap, pub(crate) mcp_dependency_prompted: HashSet, - pub(crate) turn_metadata_header_cache: HashMap>, /// Whether the session's initial context has been seeded into history. /// /// TODO(owen): This is a temporary solution to avoid updating a thread's updated_at @@ -39,7 +37,6 @@ impl SessionState { server_reasoning_included: false, dependency_env: HashMap::new(), mcp_dependency_prompted: HashSet::new(), - turn_metadata_header_cache: HashMap::new(), initial_context_seeded: false, } } @@ -128,16 +125,6 @@ impl SessionState { pub(crate) fn dependency_env(&self) -> HashMap { self.dependency_env.clone() } - - pub(crate) fn cached_turn_metadata_header(&self, cwd: &Path) -> Option> { - let key = cwd.to_string_lossy().into_owned(); - self.turn_metadata_header_cache.get(&key).cloned() - } - - pub(crate) fn set_turn_metadata_header_cache(&mut self, cwd: &Path, header: Option) { - let key = cwd.to_string_lossy().into_owned(); - self.turn_metadata_header_cache.insert(key, header); - } } // Sometimes new snapshots don't include credits or plan information.