From c2ae67d76931fcfac287d0bacf94f2b055b57da3 Mon Sep 17 00:00:00 2001 From: jif Date: Tue, 6 Oct 2026 10:28:01 +0000 Subject: [PATCH] Record multi-agent wait duration by outcome (#51332) ## What changed Record elapsed time for completed `wait_agent` waits in `codex.multi_agent.wait.duration_ms`, with an `outcome` tag of `mailbox`, `steered`, or `timed_out`. Exclude dropped waits because they have no observed outcome. GitOrigin-RevId: 6378b98bfadab69d47aa2e9c93fa9d720f9cd0ef --- .../src/tools/handlers/multi_agents_v2/wait.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/codex-rs/core/src/tools/handlers/multi_agents_v2/wait.rs b/codex-rs/core/src/tools/handlers/multi_agents_v2/wait.rs index d2f92feb8d..83458d1891 100644 --- a/codex-rs/core/src/tools/handlers/multi_agents_v2/wait.rs +++ b/codex-rs/core/src/tools/handlers/multi_agents_v2/wait.rs @@ -91,8 +91,23 @@ impl Handler { ) .await; - let deadline = Instant::now() + Duration::from_millis(timeout_ms as u64); + let wait_started = Instant::now(); + let deadline = wait_started + Duration::from_millis(timeout_ms as u64); let outcome = wait_for_activity(&mut activity_rx, pending_activity, deadline).await; + // A completed wait may wake for a message, user input, or its timeout. + // Dropped waits do not have an observed outcome and are not included. + turn.session_telemetry.record_duration( + "codex.multi_agent.wait.duration_ms", + wait_started.elapsed(), + &[( + "outcome", + match outcome { + WaitOutcome::MailboxActivity => "mailbox", + WaitOutcome::Steered => "steered", + WaitOutcome::TimedOut => "timed_out", + }, + )], + ); let result = WaitAgentResult::from_outcome(outcome, requested_timeout_ms, timeout_ms); session