Lightweight coding agent that runs in your terminal
Rust
Skip stored title lookups for ephemeral forks (#47342)
Keyan Zhangd93909a939e4
diff --git a/codex-rs/core/src/session/session.rs b/codex-rs/core/src/session/session.rsindex 917acf1577..cc52c2bf93 100644--- a/codex-rs/core/src/session/session.rs+++ b/codex-rs/core/src/session/session.rs@@ -1432,12 +1432,18 @@ impl Session {"session_init.plugin_skill_warmup",otel.name = "session_init.plugin_skill_warmup",));- let thread_name_lookup =- thread_title_from_thread_store(live_thread.as_ref(), &thread_store, thread_id)- .instrument(info_span!(- "session_init.thread_name_lookup",- otel.name = "session_init.thread_name_lookup",- ));+ let thread_name_lookup = async {+ if config.ephemeral && matches!(&initial_history, InitialHistory::Forked(_)) {+ None+ } else {+ thread_title_from_thread_store(live_thread.as_ref(), &thread_store, thread_id)+ .await+ }+ }+ .instrument(info_span!(+ "session_init.thread_name_lookup",+ otel.name = "session_init.thread_name_lookup",+ ));let (instruction_refresh, plugin_skill_errors, thread_name) = tokio::join!(agents_md_manager.refresh(config.as_ref(), &resolved_environments),plugin_skill_warmup,diff --git a/codex-rs/core/tests/suite/fork_thread.rs b/codex-rs/core/tests/suite/fork_thread.rsindex a51aa68d07..078bfd311b 100644--- a/codex-rs/core/tests/suite/fork_thread.rs+++ b/codex-rs/core/tests/suite/fork_thread.rs@@ -16,6 +16,7 @@ use codex_protocol::protocol::ThreadSettingsAppliedEvent;use codex_protocol::protocol::ThreadSettingsOverrides;use codex_protocol::protocol::ThreadSettingsSnapshot;use codex_protocol::user_input::UserInput;+use codex_thread_store::InMemoryThreadStore;use core_test_support::responses::ev_completed;use core_test_support::responses::ev_response_created;use core_test_support::responses::sse;@@ -23,12 +24,43 @@ use core_test_support::skip_if_no_network;use core_test_support::submit_thread_settings;use core_test_support::test_codex::test_codex;use core_test_support::wait_for_event;+use pretty_assertions::assert_eq;use wiremock::Mock;use wiremock::MockServer;use wiremock::ResponseTemplate;use wiremock::matchers::method;use wiremock::matchers::path;+#[tokio::test(flavor = "multi_thread", worker_threads = 2)]+async fn ephemeral_fork_skips_stored_title_lookup() -> anyhow::Result<()> {+ skip_if_no_network!(Ok(()));++ let server = MockServer::start().await;+ let store = Arc::new(InMemoryThreadStore::default());+ let test = test_codex()+ .with_thread_store(store.clone())+ .build_with_auto_env(&server)+ .await?;+ let mut config = test.config.clone();+ config.ephemeral = true;+ let reads_before = store.calls().await.read_thread;++ test.thread_manager+ .fork_thread_from_history(+ ForkSnapshot::Interrupted,+ codex_core::StartThreadOptions::new(config),+ InitialHistory::Resumed(ResumedHistory {+ conversation_id: test.session_configured.thread_id,+ history: Arc::new(Vec::new()),+ rollout_path: None,+ }),+ )+ .await?;++ assert_eq!(store.calls().await.read_thread, reads_before);+ Ok(())+}+#[tokio::test(flavor = "multi_thread", worker_threads = 2)]async fn fork_thread_twice_drops_to_first_message() {skip_if_no_network!();