From 41acdad2466628487911f985ece0ca2880ac6c1e Mon Sep 17 00:00:00 2001 From: jif Date: Tue, 6 Oct 2026 10:27:41 +0000 Subject: [PATCH] Track sub-agent result delivery outcomes (#51331) ## What changed Increment `codex.multi_agent.result_delivery` when sending a terminal child result to its parent, with `outcome=queued` for queue acceptance and `outcome=failed` for delivery errors. GitOrigin-RevId: 7571f66c2c2d2baea1a54dce3741f6393e809b66 --- codex-rs/core/src/agent/control/completion.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/codex-rs/core/src/agent/control/completion.rs b/codex-rs/core/src/agent/control/completion.rs index 8e041dcf70..48a468ea21 100644 --- a/codex-rs/core/src/agent/control/completion.rs +++ b/codex-rs/core/src/agent/control/completion.rs @@ -1,7 +1,7 @@ //! Delivers terminal child results and completion activity to the agent tree. //! //! Sessions capture terminal state; the controller owns routing and queue-only delivery. -//! Delivery remains best effort, with tracing recorded only after the parent accepts it. +//! Delivery remains best effort; metrics distinguish queue acceptance from delivery failure. use super::LocalAgentControl; use crate::TurnStartOptions; @@ -116,15 +116,25 @@ impl LocalAgentControl { ); let context = AgentCommunicationContext::new(AgentCommunicationKind::Result, outcome.thread_id); - if let Err(err) = self + let delivery = self .send_inter_agent_communication( parent_thread_id, communication, context, TurnStartOptions::default(), ) - .await - { + .await; + if let Some(metrics) = codex_otel::global() { + let _ = metrics.counter( + "codex.multi_agent.result_delivery", + /*inc*/ 1, + &[( + "outcome", + if delivery.is_ok() { "queued" } else { "failed" }, + )], + ); + } + if let Err(err) = delivery { debug!("failed to notify parent thread {parent_thread_id}: {err}"); return; }