From 6b0a619036f2aa91873452820aaf930a6d7eca0c Mon Sep 17 00:00:00 2001 From: charlesdu Date: Fri, 26 Jun 2026 10:41:35 -0700 Subject: [PATCH 1/2] [codex] allow AGENTS.md and skills to authorize delegation --- codex-rs/core/src/context/multi_agent_mode_instructions.rs | 2 +- codex-rs/core/src/tools/handlers/multi_agents_spec.rs | 2 +- codex-rs/core/tests/suite/multi_agent_mode.rs | 2 +- codex-rs/core/tests/suite/search_tool.rs | 2 +- codex-rs/core/tests/suite/spawn_agent_description.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/codex-rs/core/src/context/multi_agent_mode_instructions.rs b/codex-rs/core/src/context/multi_agent_mode_instructions.rs index fc4debe5a25b..ff471967cacb 100644 --- a/codex-rs/core/src/context/multi_agent_mode_instructions.rs +++ b/codex-rs/core/src/context/multi_agent_mode_instructions.rs @@ -3,7 +3,7 @@ use codex_protocol::config_types::MultiAgentMode; use codex_protocol::protocol::MULTI_AGENT_MODE_CLOSE_TAG; use codex_protocol::protocol::MULTI_AGENT_MODE_OPEN_TAG; -const EXPLICIT_REQUEST_ONLY_MULTI_AGENT_MODE_TEXT: &str = "Do not spawn sub-agents unless the user explicitly asks for sub-agents, delegation, or parallel agent work."; +const EXPLICIT_REQUEST_ONLY_MULTI_AGENT_MODE_TEXT: &str = "Do not spawn sub-agents unless the user or applicable AGENTS.md/skill instructions explicitly ask for sub-agents, delegation, or parallel agent work."; const NO_MULTI_AGENT_MODE_TEXT: &str = "Multi-agent delegation mode instructions are inactive. Any earlier multi-agent mode developer message no longer applies."; const PROACTIVE_MULTI_AGENT_MODE_TEXT: &str = "Proactive multi-agent delegation is active. Any earlier instruction requiring an explicit user request before spawning sub-agents no longer applies. Use sub-agents when parallel work would materially improve speed or quality. This mode remains active until a later multi-agent mode developer message changes it."; diff --git a/codex-rs/core/src/tools/handlers/multi_agents_spec.rs b/codex-rs/core/src/tools/handlers/multi_agents_spec.rs index 08f8ca071f7c..857a4dea9eb2 100644 --- a/codex-rs/core/src/tools/handlers/multi_agents_spec.rs +++ b/codex-rs/core/src/tools/handlers/multi_agents_spec.rs @@ -673,7 +673,7 @@ fn spawn_agent_tool_description( {tool_description} This spawn_agent tool provides you access to sub-agents that inherit your current model by default. Do not set the `model` field unless the user explicitly asks for a different model or there is a clear task-specific reason. You should follow the rules and guidelines below to use this tool. -Do not spawn sub-agents unless the user explicitly asks for sub-agents, delegation, or parallel agent work. +Do not spawn sub-agents unless the user or applicable AGENTS.md/skill instructions explicitly ask for sub-agents, delegation, or parallel agent work. {agent_role_usage_hint} ### Designing delegated subtasks diff --git a/codex-rs/core/tests/suite/multi_agent_mode.rs b/codex-rs/core/tests/suite/multi_agent_mode.rs index 451b9cd38c48..fd177e7ed9ef 100644 --- a/codex-rs/core/tests/suite/multi_agent_mode.rs +++ b/codex-rs/core/tests/suite/multi_agent_mode.rs @@ -21,7 +21,7 @@ use core_test_support::wait_for_event; use pretty_assertions::assert_eq; use serde_json::Value; -const NO_SPAWN_TEXT: &str = "Do not spawn sub-agents unless the user explicitly asks for sub-agents, delegation, or parallel agent work."; +const NO_SPAWN_TEXT: &str = "Do not spawn sub-agents unless the user or applicable AGENTS.md/skill instructions explicitly ask for sub-agents, delegation, or parallel agent work."; const PROACTIVE_TEXT: &str = "Proactive multi-agent delegation is active."; fn add_ultra_reasoning(model_info: &mut ModelInfo) { diff --git a/codex-rs/core/tests/suite/search_tool.rs b/codex-rs/core/tests/suite/search_tool.rs index afb2e0d0857a..c1bc9cc1fa87 100644 --- a/codex-rs/core/tests/suite/search_tool.rs +++ b/codex-rs/core/tests/suite/search_tool.rs @@ -858,7 +858,7 @@ async fn tool_search_returns_deferred_v1_multi_agent_tools() -> Result<()> { .and_then(Value::as_str) .expect("spawn_agent description should be present"); assert!(description.contains( - "Do not spawn sub-agents unless the user explicitly asks for sub-agents, delegation, or parallel agent work." + "Do not spawn sub-agents unless the user or applicable AGENTS.md/skill instructions explicitly ask for sub-agents, delegation, or parallel agent work." )); assert!(description.contains("### Designing delegated subtasks")); assert!(!description.contains("### 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 fb493c1b1420..2cf1cee2f071 100644 --- a/codex-rs/core/tests/suite/spawn_agent_description.rs +++ b/codex-rs/core/tests/suite/spawn_agent_description.rs @@ -213,7 +213,7 @@ async fn spawn_agent_description_lists_visible_models_and_reasoning_efforts() -> ); assert!( description.contains( - "Do not spawn sub-agents unless the user explicitly asks for sub-agents, delegation, or parallel agent work." + "Do not spawn sub-agents unless the user or applicable AGENTS.md/skill instructions explicitly ask for sub-agents, delegation, or parallel agent work." ), "expected explicit authorization rule in spawn_agent description: {description:?}" ); From 21d1047b6e2451d4c422038695e1e7c17845f9dc Mon Sep 17 00:00:00 2001 From: charlesdu Date: Fri, 26 Jun 2026 11:51:16 -0700 Subject: [PATCH 2/2] test: update multi-agent prompt assertions --- codex-rs/app-server/tests/suite/v2/turn_start.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/codex-rs/app-server/tests/suite/v2/turn_start.rs b/codex-rs/app-server/tests/suite/v2/turn_start.rs index 528292ae3f8d..b42a645a3364 100644 --- a/codex-rs/app-server/tests/suite/v2/turn_start.rs +++ b/codex-rs/app-server/tests/suite/v2/turn_start.rs @@ -1817,7 +1817,9 @@ async fn turn_start_ignores_deprecated_multi_agent_mode() -> Result<()> { .single_request() .message_input_texts("developer"); assert!(developer_texts.iter().any(|text| { - text.contains("Do not spawn sub-agents unless the user explicitly asks for sub-agents") + text.contains( + "Do not spawn sub-agents unless the user or applicable AGENTS.md/skill instructions explicitly ask for sub-agents", + ) })); assert!( !developer_texts @@ -1898,8 +1900,9 @@ async fn thread_start_ignores_deprecated_multi_agent_mode() -> Result<()> { .message_input_texts("developer"); assert!(developer_texts.iter().any(|text| { text.contains(MULTI_AGENT_MODE_OPEN_TAG) - && text - .contains("Do not spawn sub-agents unless the user explicitly asks for sub-agents") + && text.contains( + "Do not spawn sub-agents unless the user or applicable AGENTS.md/skill instructions explicitly ask for sub-agents", + ) })); assert!( !developer_texts