diff --git a/codex-rs/core/src/tools/spec.rs b/codex-rs/core/src/tools/spec.rs index 3364d19e8..afa4c1861 100644 --- a/codex-rs/core/src/tools/spec.rs +++ b/codex-rs/core/src/tools/spec.rs @@ -853,7 +853,10 @@ fn create_spawn_agent_tool(config: &ToolsConfig) -> ToolSpec { name: "spawn_agent".to_string(), description: format!( r#" - Only use `spawn_agent` if and only if the user explicitly asked for sub-agents or parallel agent work. 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. This spawn_agent tool provides you access to smaller but more efficient sub-agents. A mini model can solve many tasks faster than the main model. You should follow the rules and guidelines below to use this tool. + Only use `spawn_agent` if and only if the user explicitly asks for sub-agents, delegation, or parallel agent work. + Requests for depth, thoroughness, research, investigation, or detailed codebase analysis do not count as permission to spawn. + Agent-role guidance below only helps choose which agent to use after spawning is already authorized; it never authorizes spawning by itself. + 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. This spawn_agent tool provides you access to smaller but more efficient sub-agents. A mini model can solve many tasks faster than the main model. You should follow the rules and guidelines below to use this tool. {available_models_description} ### When to delegate vs. do the subtask yourself diff --git a/codex-rs/core/tests/suite/spawn_agent_description.rs b/codex-rs/core/tests/suite/spawn_agent_description.rs index ad822805a..117d1d9ef 100644 --- a/codex-rs/core/tests/suite/spawn_agent_description.rs +++ b/codex-rs/core/tests/suite/spawn_agent_description.rs @@ -180,6 +180,24 @@ async fn spawn_agent_description_lists_visible_models_and_reasoning_efforts() -> !description.contains("Hidden Model"), "hidden picker model should be omitted from spawn_agent description: {description:?}" ); + assert!( + description.contains( + "Only use `spawn_agent` if and only if the user explicitly asks for sub-agents, delegation, or parallel agent work." + ), + "expected explicit authorization rule in spawn_agent description: {description:?}" + ); + assert!( + description.contains( + "Requests for depth, thoroughness, research, investigation, or detailed codebase analysis do not count as permission to spawn." + ), + "expected non-authorization clarification in spawn_agent description: {description:?}" + ); + assert!( + description.contains( + "Agent-role guidance below only helps choose which agent to use after spawning is already authorized; it never authorizes spawning by itself." + ), + "expected agent-role clarification in spawn_agent description: {description:?}" + ); Ok(()) }