From acd5ed9207cd65239f67182829b585b09c7d19fb Mon Sep 17 00:00:00 2001 From: felixxia-oai Date: Wed, 23 Sep 2026 15:00:30 +0000 Subject: [PATCH] Wait for idle before injecting remote compaction test history (#47571) ## Why Turn completion precedes active-turn cleanup, so the remote compaction test must wait for the thread to become idle before injecting its history fixture. ## What changed Register the `ThreadIdle` lifecycle contributor and wait after the initial turn in `remote_compact_v2_rewrites_multiple_trailing_function_call_outputs`, covering both manual and automatic compaction cases. GitOrigin-RevId: 1593b212db0e07b1457f090b5ac7ba2313a28360 --- codex-rs/core/tests/suite/compact_remote.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/codex-rs/core/tests/suite/compact_remote.rs b/codex-rs/core/tests/suite/compact_remote.rs index 28821bb3bb..76032f34ef 100644 --- a/codex-rs/core/tests/suite/compact_remote.rs +++ b/codex-rs/core/tests/suite/compact_remote.rs @@ -6,6 +6,7 @@ use base64::Engine; use base64::engine::general_purpose::STANDARD as BASE64_STANDARD; use codex_core::StartThreadOptions; use codex_core::TurnInputRequest; +use codex_extension_api::ExtensionRegistryBuilder; use codex_features::Feature; use codex_history::CodexHarnessMetadata; use codex_history::InitialHistory; @@ -28,6 +29,7 @@ use codex_protocol::protocol::RealtimeEvent; use codex_protocol::protocol::RealtimeOutputModality; use codex_protocol::protocol::ThreadHistoryMode; use codex_protocol::user_input::UserInput; +use core_test_support::ThreadIdle; use core_test_support::responses; use core_test_support::responses::mount_sse_once; use core_test_support::responses::sse; @@ -44,6 +46,7 @@ use serde_json::Value; use serde_json::json; use std::fs; use std::path::Path; +use std::sync::Arc; use test_case::test_case; use tokio::time::Duration; use wiremock::ResponseTemplate; @@ -1295,8 +1298,11 @@ async fn remote_compact_v2_rewrites_multiple_trailing_function_call_outputs( let second_trimmed_call_id = "second-trimmed-call"; let retained_output = "retained tool output"; + let mut extensions = ExtensionRegistryBuilder::new(); + extensions.thread_lifecycle_contributor(Arc::new(ThreadIdle)); let harness = TestCodexHarness::with_builder( test_codex() + .with_extensions(Arc::new(extensions.build())) .with_auth(CodexAuth::create_dummy_chatgpt_auth_for_testing()) .with_config(|config| { config.model_context_window = Some(2_000); @@ -1316,6 +1322,8 @@ async fn remote_compact_v2_rewrites_multiple_trailing_function_call_outputs( .await; harness.test().submit_turn("initial turn").await?; let _ = initial_mock.single_request(); + // Completion precedes active-turn cleanup; inject the fixture into idle history. + ThreadIdle::wait(&codex).await; let history = [ json!({"type": "message", "role": "user", "content": [{"type": "input_text", "text": first_user_message}]}), json!({"type": "function_call", "call_id": retained_call_id, "name": "exec_command", "arguments": "{}"}),