Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Wait for idle before injecting remote compaction test history (#47571)

felixxia-oaiacd5ed9207cd
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": "{}"}),