From cf4ceb239a599f6f448fc55c09187583922bc24e Mon Sep 17 00:00:00 2001 From: Charles Cunningham Date: Fri, 13 Mar 2026 14:19:46 -0700 Subject: [PATCH] Relax flaky spawn-agent status assertion Allow the child agent state to be either PendingInit or Running when the spawn completion notification arrives. Co-authored-by: Codex --- .../app-server/tests/suite/v2/turn_start.rs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/codex-rs/app-server/tests/suite/v2/turn_start.rs b/codex-rs/app-server/tests/suite/v2/turn_start.rs index ea46d06a5c..e482825d98 100644 --- a/codex-rs/app-server/tests/suite/v2/turn_start.rs +++ b/codex-rs/app-server/tests/suite/v2/turn_start.rs @@ -13,7 +13,6 @@ use codex_app_server::INPUT_TOO_LARGE_ERROR_CODE; use codex_app_server::INVALID_PARAMS_ERROR_CODE; use codex_app_server_protocol::ByteRange; use codex_app_server_protocol::ClientInfo; -use codex_app_server_protocol::CollabAgentState; use codex_app_server_protocol::CollabAgentStatus; use codex_app_server_protocol::CollabAgentTool; use codex_app_server_protocol::CollabAgentToolCallStatus; @@ -2213,15 +2212,19 @@ async fn turn_start_emits_spawn_agent_item_with_model_metadata_v2() -> Result<() assert_eq!(prompt, Some(CHILD_PROMPT.to_string())); assert_eq!(model, Some(REQUESTED_MODEL.to_string())); assert_eq!(reasoning_effort, Some(REQUESTED_REASONING_EFFORT)); + let receiver_state = agents_states + .get(&receiver_thread_id) + .expect("spawn completion should include child thread state"); + assert!( + matches!( + receiver_state.status, + CollabAgentStatus::PendingInit | CollabAgentStatus::Running + ), + "expected child status to still be initializing or already running, got {receiver_state:?}" + ); assert_eq!( - agents_states, - HashMap::from([( - receiver_thread_id, - CollabAgentState { - status: CollabAgentStatus::PendingInit, - message: None, - }, - )]) + receiver_state.message, None, + "spawn completion should not carry a final child message yet" ); let turn_completed = timeout(DEFAULT_READ_TIMEOUT, async {