From 4449734da4e3550746695f71fdc93af536b7483f Mon Sep 17 00:00:00 2001 From: Chris Bookholt Date: Mon, 29 Jun 2026 21:49:57 -0700 Subject: [PATCH] [core] wait for matching encrypted agent request --- .../tests/suite/subagent_notifications.rs | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/codex-rs/core/tests/suite/subagent_notifications.rs b/codex-rs/core/tests/suite/subagent_notifications.rs index 951fb92f17..1d648a3d0b 100644 --- a/codex-rs/core/tests/suite/subagent_notifications.rs +++ b/codex-rs/core/tests/suite/subagent_notifications.rs @@ -342,6 +342,26 @@ async fn wait_for_requests( } } +async fn wait_for_request_with_input_type( + mock: &core_test_support::responses::ResponseMock, + ty: &str, +) -> Result { + let deadline = Instant::now() + Duration::from_secs(2); + loop { + if let Some(request) = mock + .requests() + .into_iter() + .find(|request| !request.inputs_of_type(ty).is_empty()) + { + return Ok(request); + } + if Instant::now() >= deadline { + anyhow::bail!("expected a captured request with input type {ty:?}"); + } + sleep(Duration::from_millis(10)).await; + } +} + async fn setup_turn_one_with_spawned_child( server: &MockServer, child_response_delay: Option, @@ -1101,10 +1121,8 @@ async fn encrypted_multi_agent_v2_spawn_sends_agent_message_to_child() -> Result test.submit_turn(TURN_1_PROMPT).await?; - let child_request = wait_for_requests(&child_request_log) - .await? - .pop() - .expect("child request"); + let child_request = + wait_for_request_with_input_type(&child_request_log, "agent_message").await?; assert_eq!( strip_metadata_from_json(Value::Array(child_request.inputs_of_type("agent_message"))), Value::Array(vec![json!({