Skip to content

Commit 8dac605

Browse files
authored
[codex] Restore v1 delegation guidance (#30511)
## Summary - restore the v1 clarification that requests for depth, research, or investigation do not authorize subagent spawning - restore guidance for keeping critical-path, urgent, tightly coupled, or difficult work local - update the focused v1 tool-search and spawn-description coverage ## Why PR #27919 simplified the v1 `spawn_agent` prompt by removing its delegation decision guidance. That left the authorization rule intact, but removed the instructions that constrained what should be delegated after spawning was authorized. Restore those guardrails while preserving later support for explicit delegation authorization from applicable AGENTS.md and skill instructions. Multi-agent v2 prompts are unchanged. ## User impact Models using the v1 multi-agent tool surface receive clearer guidance to delegate independent side work while keeping blocking work on the main rollout. ## Validation - `just fmt` - `git diff --check` - tests not run locally per repository guidance; CI will validate the focused coverage
1 parent 6b5f574 commit 8dac605

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

codex-rs/core/src/tools/handlers/multi_agents_spec.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,15 @@ fn spawn_agent_tool_description(
674674
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.
675675
676676
Do not spawn sub-agents unless the user or applicable AGENTS.md/skill instructions explicitly ask for sub-agents, delegation, or parallel agent work.
677+
Requests for depth, thoroughness, research, investigation, or detailed codebase analysis do not count as permission to spawn.
677678
{agent_role_usage_hint}
678679
680+
### When to delegate vs. do the subtask yourself
681+
- First, quickly analyze the overall user task and form a succinct high-level plan. Identify which tasks are immediate blockers on the critical path, and which tasks are sidecar tasks that are needed but can run in parallel without blocking the next local step. As part of that plan, explicitly decide what immediate task you should do locally right now. Do this planning step before delegating to agents so you do not hand off the immediate blocking task to a submodel and then waste time waiting on it.
682+
- Use a subagent when a subtask is easy enough for it to handle and can run in parallel with your local work. Prefer delegating concrete, bounded sidecar tasks that materially advance the main task without blocking your immediate next local step.
683+
- Do not delegate urgent blocking work when your immediate next step depends on that result. If the very next action is blocked on that task, the main rollout should usually do it locally to keep the critical path moving.
684+
- Keep work local when the subtask is too difficult to delegate well and when it is tightly coupled, urgent, or likely to block your immediate next step.
685+
679686
### Designing delegated subtasks
680687
- Subtasks must be concrete, well-defined, and self-contained.
681688
- Delegated subtasks must materially advance the main task.

codex-rs/core/tests/suite/search_tool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ async fn tool_search_returns_deferred_v1_multi_agent_tools() -> Result<()> {
827827
assert!(
828828
!first_request_body
829829
.to_string()
830-
.contains("Only use `spawn_agent` if and only if"),
830+
.contains("### When to delegate vs. do the subtask yourself"),
831831
"deferred v1 multi-agent guidance should stay out of initial developer context"
832832
);
833833

@@ -861,7 +861,7 @@ async fn tool_search_returns_deferred_v1_multi_agent_tools() -> Result<()> {
861861
"Do not spawn sub-agents unless the user or applicable AGENTS.md/skill instructions explicitly ask for sub-agents, delegation, or parallel agent work."
862862
));
863863
assert!(description.contains("### Designing delegated subtasks"));
864-
assert!(!description.contains("### When to delegate vs. do the subtask yourself"));
864+
assert!(description.contains("### When to delegate vs. do the subtask yourself"));
865865

866866
Ok(())
867867
}

codex-rs/core/tests/suite/spawn_agent_description.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,10 @@ async fn spawn_agent_description_lists_visible_models_and_reasoning_efforts() ->
219219
"expected explicit authorization rule in spawn_agent description: {description:?}"
220220
);
221221
assert!(
222-
!description.contains("### When to delegate vs. do the subtask yourself"),
223-
"spawn_agent description should not include extra when-to-use delegation guidance: {description:?}"
222+
description.contains(
223+
"Requests for depth, thoroughness, research, investigation, or detailed codebase analysis do not count as permission to spawn."
224+
) && description.contains("### When to delegate vs. do the subtask yourself"),
225+
"expected delegation decision guidance in spawn_agent description: {description:?}"
224226
);
225227
assert!(
226228
description.contains(

0 commit comments

Comments
 (0)