Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Track sub-agent result delivery outcomes (#51331)

jif41acdad24666
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;
}