From cf0210bf22c5b2f0dbf5c2610add895f6ee8e96b Mon Sep 17 00:00:00 2001 From: jif-oai Date: Mon, 23 Feb 2026 13:44:37 +0000 Subject: [PATCH] feat: agent nick names to model (#12575) --- .../core/src/tools/handlers/multi_agents.rs | 17 +++++++++++++++++ codex-rs/core/src/tools/spec.rs | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/codex-rs/core/src/tools/handlers/multi_agents.rs b/codex-rs/core/src/tools/handlers/multi_agents.rs index ae72c8b1e..a736a8cfb 100644 --- a/codex-rs/core/src/tools/handlers/multi_agents.rs +++ b/codex-rs/core/src/tools/handlers/multi_agents.rs @@ -109,6 +109,7 @@ mod spawn { #[derive(Debug, Serialize)] struct SpawnAgentResult { agent_id: String, + nickname: Option, } pub async fn handle( @@ -183,6 +184,7 @@ mod spawn { .unwrap_or((None, None)), None => (None, None), }; + let nickname = new_agent_nickname.clone(); session .send_event( &turn, @@ -202,6 +204,7 @@ mod spawn { let content = serde_json::to_string(&SpawnAgentResult { agent_id: new_thread_id.to_string(), + nickname, }) .map_err(|err| { FunctionCallError::Fatal(format!("failed to serialize spawn_agent result: {err}")) @@ -1085,6 +1088,7 @@ mod tests { #[derive(Debug, Deserialize)] struct SpawnAgentResult { agent_id: String, + nickname: Option, } let (mut session, mut turn) = make_session_and_context().await; @@ -1121,6 +1125,12 @@ mod tests { let result: SpawnAgentResult = serde_json::from_str(&content).expect("spawn_agent result should be json"); let agent_id = agent_id(&result.agent_id).expect("agent_id should be valid"); + assert!( + result + .nickname + .as_deref() + .is_some_and(|nickname| !nickname.is_empty()) + ); let snapshot = manager .get_thread(agent_id) .await @@ -1184,6 +1194,7 @@ mod tests { #[derive(Debug, Deserialize)] struct SpawnAgentResult { agent_id: String, + nickname: Option, } let (mut session, mut turn) = make_session_and_context().await; @@ -1221,6 +1232,12 @@ mod tests { let result: SpawnAgentResult = serde_json::from_str(&content).expect("spawn_agent result should be json"); assert!(!result.agent_id.is_empty()); + assert!( + result + .nickname + .as_deref() + .is_some_and(|nickname| !nickname.is_empty()) + ); assert_eq!(success, Some(true)); } diff --git a/codex-rs/core/src/tools/spec.rs b/codex-rs/core/src/tools/spec.rs index 7bd1fc978..84a69c3ad 100644 --- a/codex-rs/core/src/tools/spec.rs +++ b/codex-rs/core/src/tools/spec.rs @@ -557,7 +557,7 @@ fn create_spawn_agent_tool(config: &ToolsConfig) -> ToolSpec { ToolSpec::Function(ResponsesApiTool { name: "spawn_agent".to_string(), description: - "Spawn a sub-agent for a well-scoped task. Returns the agent id to use to communicate with this agent." + "Spawn a sub-agent for a well-scoped task. Returns the agent id (and user-facing nickname when available) to use to communicate with this agent." .to_string(), strict: false, parameters: JsonSchema::Object {