mirror of
https://github.com/openai/codex.git
synced 2026-11-29 00:00:54 +00:00
Skip stored title lookups for ephemeral forks (#47342)
## What changed Skip the thread store title lookup when initializing an ephemeral fork, leaving its thread name unset. ## Testing Add a regression test that forks an ephemeral thread from history and verifies that the in-memory thread store's `read_thread` count does not increase. GitOrigin-RevId: 81180c4a836c932584d2cb94c0816eae33b04af3
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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!();
|
||||
|
||||
Reference in New Issue
Block a user