From f94b5d899ae8e2785f4f028d35055d4be6b9dca3 Mon Sep 17 00:00:00 2001 From: jif Date: Mon, 3 Aug 2026 16:39:07 +0000 Subject: [PATCH] Stabilize deferred goal fork testing (#36770) ## What changed - Restart the test app server before injecting the source thread's active goal so a late idle hook cannot continue it. - Remove the unrelated ordinary-fork assertion and keep the scenario focused on deferred goal continuation across paginated forks. GitOrigin-RevId: 5383f56ffa1687a4ebd18b5e37cbd61290fa59a7 --- .../app-server/tests/suite/v2/thread_fork.rs | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/codex-rs/app-server/tests/suite/v2/thread_fork.rs b/codex-rs/app-server/tests/suite/v2/thread_fork.rs index ebcc6a50f6..ba837e1f01 100644 --- a/codex-rs/app-server/tests/suite/v2/thread_fork.rs +++ b/codex-rs/app-server/tests/suite/v2/thread_fork.rs @@ -660,7 +660,14 @@ async fn thread_fork_defers_inherited_active_goal_until_next_turn() -> Result<() .await??; turn_ids.push(completed.turn.id); } - mcp.clear_message_buffer(); + // Stop the source before its active goal exists so a late idle hook cannot continue it. + timeout(DEFAULT_READ_TIMEOUT, mcp.shutdown_gracefully()).await??; + drop(mcp); + let mut mcp = TestAppServer::builder() + .with_codex_home(codex_home.path()) + .without_managed_config() + .build_initialized() + .await?; let state_db = StateRuntime::init( codex_state::SqliteConfig::new_for_testing(codex_home.path().abs()), @@ -692,24 +699,6 @@ async fn thread_fork_defers_inherited_active_goal_until_next_turn() -> Result<() .await? .expect("source goal"); - let ordinary_fork_id = mcp - .send_thread_fork_request(ThreadForkParams { - thread_id: source_thread.id.clone(), - ..Default::default() - }) - .await?; - let ThreadForkResponse { - thread: ordinary_fork, - .. - } = timeout(DEFAULT_READ_TIMEOUT, mcp.read_response(ordinary_fork_id)).await??; - assert_eq!( - state_db - .thread_goals() - .get_thread_goal(ThreadId::from_string(&ordinary_fork.id)?) - .await?, - None - ); - let mut forked_threads = Vec::new(); for (last_turn_id, before_turn_id, expected_turn_count) in [ (None, None, 2),