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 <noreply@openai.com>
This commit is contained in:
Charles Cunningham
2026-03-13 14:19:46 -07:00
parent 55b9ad1490
commit cf4ceb239a

View File

@@ -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 {