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
This commit is contained in:
jif
2026-10-06 10:41:24 +00:00
committed by copyberry
parent f5fa209bb0
commit 41acdad246
+14 -4
View File
@@ -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;
}