Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

feat: role metrics multi-agent (#12579)

jif-oai2119532a8128
diff --git a/codex-rs/core/src/agent/guards.rs b/codex-rs/core/src/agent/guards.rs
index 223373c6df..422e10b651 100644
--- a/codex-rs/core/src/agent/guards.rs
+++ b/codex-rs/core/src/agent/guards.rs
@@ -118,6 +118,9 @@ impl Guards {
} else {
active_agents.used_agent_nicknames.clear();
active_agents.nickname_reset_count += 1;
+ if let Some(metrics) = codex_otel::metrics::global() {
+ let _ = metrics.counter("codex.multi_agent.nickname_pool_reset", 1, &[]);
+ }
names.choose(&mut rand::rng())?.to_string()
}
};
diff --git a/codex-rs/core/src/agent/role.rs b/codex-rs/core/src/agent/role.rs
index a72ba23469..8cc18c1ad1 100644
--- a/codex-rs/core/src/agent/role.rs
+++ b/codex-rs/core/src/agent/role.rs
@@ -13,7 +13,7 @@ use std::path::Path;
use std::sync::LazyLock;
use toml::Value as TomlValue;
-const DEFAULT_ROLE_NAME: &str = "default";
+pub const DEFAULT_ROLE_NAME: &str = "default";
const AGENT_TYPE_UNAVAILABLE_ERROR: &str = "agent type is currently not available";
/// Applies a role config layer to a mutable config and preserves unspecified keys.
diff --git a/codex-rs/core/src/tools/handlers/multi_agents.rs b/codex-rs/core/src/tools/handlers/multi_agents.rs
index a736a8cfb6..20be209fbe 100644
--- a/codex-rs/core/src/tools/handlers/multi_agents.rs
+++ b/codex-rs/core/src/tools/handlers/multi_agents.rs
@@ -93,6 +93,7 @@ impl ToolHandler for MultiAgentHandler {
mod spawn {
use super::*;
+ use crate::agent::role::DEFAULT_ROLE_NAME;
use crate::agent::role::apply_role_to_config;
use crate::agent::exceeds_thread_spawn_depth_limit;
@@ -201,6 +202,9 @@ mod spawn {
)
.await;
let new_thread_id = result?;
+ let role_tag = role_name.unwrap_or(DEFAULT_ROLE_NAME);
+ turn.otel_manager
+ .counter("codex.multi_agent.spawn", 1, &[("role", role_tag)]);
let content = serde_json::to_string(&SpawnAgentResult {
agent_id: new_thread_id.to_string(),
@@ -409,6 +413,8 @@ mod resume_agent {
if let Some(err) = error {
return Err(err);
}
+ turn.otel_manager
+ .counter("codex.multi_agent.resume", 1, &[]);
let content = serde_json::to_string(&ResumeAgentResult { status }).map_err(|err| {
FunctionCallError::Fatal(format!("failed to serialize resume_agent result: {err}"))