From fc0d710b257a6c8549a69daf402b005d861ece41 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Mon, 19 Jan 2026 09:51:25 -0800 Subject: [PATCH] fix --- codex-rs/core/src/codex.rs | 13 +++++------ .../core/src/context_manager/history_tests.rs | 22 +++++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 785ce3e9f7..dbef5a7d53 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -3544,8 +3544,7 @@ mod tests { session_source: SessionSource::Exec, }; - let conversation_id = ThreadId::default(); - let mut state = SessionState::new(session_configuration, conversation_id); + let mut state = SessionState::new(session_configuration); let initial = RateLimitSnapshot { primary: Some(RateLimitWindow { used_percent: 10.0, @@ -3616,8 +3615,7 @@ mod tests { session_source: SessionSource::Exec, }; - let conversation_id = ThreadId::default(); - let mut state = SessionState::new(session_configuration, conversation_id); + let mut state = SessionState::new(session_configuration); let initial = RateLimitSnapshot { primary: Some(RateLimitWindow { used_percent: 15.0, @@ -3883,7 +3881,7 @@ mod tests { session_configuration.session_source.clone(), ); - let state = SessionState::new(session_configuration.clone(), conversation_id); + let state = SessionState::new(session_configuration.clone()); let skills_manager = Arc::new(SkillsManager::new(config.codex_home.clone())); let services = SessionServices { @@ -3983,7 +3981,7 @@ mod tests { session_configuration.session_source.clone(), ); - let state = SessionState::new(session_configuration.clone(), conversation_id); + let state = SessionState::new(session_configuration.clone()); let skills_manager = Arc::new(SkillsManager::new(config.codex_home.clone())); let services = SessionServices { @@ -4293,7 +4291,8 @@ mod tests { turn_context: &TurnContext, ) -> (Vec, Vec) { let mut rollout_items = Vec::new(); - let mut live_history = ContextManager::new(); + let codex_home = session.codex_home().await; + let mut live_history = ContextManager::new(&codex_home); let initial_context = session.build_initial_context(turn_context).await; for item in &initial_context { diff --git a/codex-rs/core/src/context_manager/history_tests.rs b/codex-rs/core/src/context_manager/history_tests.rs index d123874ed8..3f0bde153f 100644 --- a/codex-rs/core/src/context_manager/history_tests.rs +++ b/codex-rs/core/src/context_manager/history_tests.rs @@ -32,7 +32,8 @@ fn assistant_msg(text: &str) -> ResponseItem { } fn create_history_with_items(items: Vec) -> ContextManager { - let mut h = ContextManager::new(); + let codex_home = PathBuf::from("/tmp"); + let mut h = ContextManager::new(&codex_home); // Use a generous but fixed token budget; tests only rely on truncation // behavior, not on a specific model's token limit. h.record_items(items.iter(), TruncationPolicy::Tokens(10_000)); @@ -89,15 +90,9 @@ fn truncate_exec_output(content: &str) -> String { #[test] fn stores_oversized_user_message_in_user_message_dir() { - let mut history = ContextManager::new(); let temp_dir = tempdir().expect("create temp dir"); - history.set_user_message_dir(Some( - temp_dir - .path() - .join("context") - .join("usermsgs") - .join("test-session"), - )); + let codex_home = temp_dir.path().to_path_buf(); + let mut history = ContextManager::new(&codex_home); history.set_token_info(Some(TokenUsageInfo { total_token_usage: TokenUsage::default(), last_token_usage: TokenUsage::default(), @@ -531,7 +526,8 @@ fn normalization_retains_local_shell_outputs() { #[test] fn record_items_truncates_function_call_output_content() { - let mut history = ContextManager::new(); + let codex_home = PathBuf::from("/tmp"); + let mut history = ContextManager::new(&codex_home); // Any reasonably small token budget works; the test only cares that // truncation happens and the marker is present. let policy = TruncationPolicy::Tokens(1_000); @@ -569,7 +565,8 @@ fn record_items_truncates_function_call_output_content() { #[test] fn record_items_truncates_custom_tool_call_output_content() { - let mut history = ContextManager::new(); + let codex_home = PathBuf::from("/tmp"); + let mut history = ContextManager::new(&codex_home); let policy = TruncationPolicy::Tokens(1_000); let line = "custom output that is very long\n"; let long_output = line.repeat(2_500); @@ -599,7 +596,8 @@ fn record_items_truncates_custom_tool_call_output_content() { #[test] fn record_items_respects_custom_token_limit() { - let mut history = ContextManager::new(); + let codex_home = PathBuf::from("/tmp"); + let mut history = ContextManager::new(&codex_home); let policy = TruncationPolicy::Tokens(10); let long_output = "tokenized content repeated many times ".repeat(200); let item = ResponseItem::FunctionCallOutput {