Subagent spawn policy conflicts with repo-level workflow instructions
What version of Codex CLI is running?
codex-cli 0.118.0
What subscription do you have?
ChatGPT Plus
Which model were you using?
gpt-5.4 with high reasoning.
What platform is your computer?
Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64
What terminal emulator and version are you using (if applicable)?
VS Code integrated terminal on WSL2 (Ubuntu 22.04).
What issue are you seeing?
Repo-level workflow instructions can require a bounded role-specific subagent, while higher-priority session policy can simultaneously disallow autonomous subagent spawning unless the user explicitly authorizes delegation.
When both apply in the same run, Codex CLI can end up with contradictory guidance about whether it may spawn a subagent at all. The effective precedence and the correct fallback are not made clear.
What steps can reproduce the bug?
- Use a repo with instructions that direct Codex to use a bounded role-specific subagent for a workflow such as test execution or code review.
- Ask Codex to perform work that reaches that workflow.
- Do not explicitly authorize delegation in the user prompt.
- Observe that Codex can reason that repo instructions require delegation while higher-priority session policy disallows autonomous subagent spawning.
What is the expected behavior?
Codex should resolve this deterministically.
- Either bounded role-specific subagents should be allowed when repo workflow requires them.
- Or the session should explicitly surface that autonomous subagent spawning is disabled.
- And if spawning is disallowed, Codex should stop and ask the user instead of forcing the agent to infer its own fallback.
Additional information
This seems broader than one repo. Any repo-level workflow that assumes autonomous use of bounded subagents can hit the same conflict.
A first-class capability signal for autonomous spawn, or explicit documentation about precedence between repo instructions and session policy, would make the behavior much clearer.
9 Comments
Same bug in codex cli 0.120.0 on Macos Tahoe
Reproduced with these steps:
I asked the agent why it didn't use a subagent:
<img width="838" height="201" alt="Image" src="https://github.com/user-attachments/assets/272b6607-271f-4da5-b494-a8e6414eaf79" />
-------------------------------------
<img width="812" height="95" alt="Image" src="https://github.com/user-attachments/assets/b4955af6-a9d7-4d36-83f7-45c253224d80" />
Here is my AGENTS.md instruction:
<img width="1132" height="99" alt="Image" src="https://github.com/user-attachments/assets/41e67592-89e1-40e7-9124-25b68038c2b9" />
This happens with a lot of my AGENTS.md instructions about subagents usage.
After-edit reviews, git lookups, websearches etc. get the same "developer instruction priority" issue
+1
I think this issue is directly related to #18319.
In my session, the same policy-conflict pattern showed up:
What made it worse in my case is that after I explicitly clarified that research should be delegated to an agent, Codex still did overlapping parent-thread work anyway.
So from my side, #16996 looks like the policy/preference/precedence half of the same broader failure mode reported in #18319: repo-level workflow intent and delegation expectations are not reconciling cleanly with higher-priority session behavior.
I literally have an entire Skill-based and Custom Agents setup centered around this workflow baked into my repo and AGENTS.md, and it still failed to follow it and claimed it was following the system/dev tool instructions, then it rebukes itself and states that obviously user instructions were clear to do the delegation, so those higher-priority instructions do not or should not have mattered. The agent is just confused and cannot follow user instructions.
and the issue is not just context bloat either, it's the core integrity and policy of my entire project based on this delegation policy workflow that requires and mandates independent blind reviews from subagents spawned, because the main agent cannot review itself, it's obviously biased towards no findings. if you simply spawn subagents to independently review the work, it will find a lot of issues the main agent never does. my entire workflow is centered around this for my project, and failing to follow it completely ruins my project, which is what happened. DAYS OF WORK WASTED, AND ANOTHER WEEK OF GOING BACK TO CLEAN UP THE MESS.
thread id: 019d8a20-42a1-7461-b1ad-f93ff7412892
Asked Codex to fix it, it suggested this addition to
~/.codex/config.toml:Now subagents work as in earlier versions of Codex and properly listen to global user instructions.
_Edit: note that this fix is brittle as it relies on undocumented configuration knobs that might potentially be removed in future builds. This should ideally be fixed by the Codex team rather than monkey patched by end users._
Adding a concrete variant of this failure mode from a long-running repo-governed workflow.
In this case the repository had an
AGENTS.md/ repo-resident workflow policy that explicitly authorized workflow-mandated role subagents. The local policy’s intent was roughly:The repo workflow was built around stage-gated role lanes:
But the main agent still treated the higher-priority generic spawn rule as requiring a fresh chat-level phrase like “spawn subagents” before using the repo-mandated role lanes. The result was that it produced stage artifacts and deterministic validator reports locally, but did not actually enact the role provenance the workflow required. In other words:
silently substituted for:
or:
This creates a subtle but serious failure mode for repo-governed workflows:
AGENTS.md/ repo policy.Expected behavior:
or the opposite:
What should not happen is silent degradation from “spawn the required role lane” to “main agent writes the role report itself.”
This also ties into long-running/compacted sessions: user-granted delegation authority should not live only in the model’s transient chat memory. If the user has explicitly placed the authority in repo policy, Codex should either honor it as a durable scoped authority surface or clearly mark it as non-authoritative under the current session policy.
Adding a current 0.133.0 reproduction from a repo-governed multi-agent workflow.
Environment:
Current signal:
tool_searchstill exposesmulti_agent_v1.spawn_agentwith the blanket gate: "Only use spawn_agent if and only if the user explicitly asks..."Primary repo surfaces already corrected:
Extra checks from today:
codex features listshowsmulti_agent=true, whilemulti_agent_v2andenable_fanoutare available but off by default.codex debug prompt-input --enable multi_agent_v2and--enable enable_fanoutproduced byte-identical prompt input to default for this case, so I could not prove a local config-only workaround changes the model-visible authorization/tool contract.Expected behavior:
The
spawn_agentmetadata should distinguish authority classes. Standing authorization from AGENTS.md / skills / repo doctrine should satisfy the ask for bounded info retrieval, validation, codebase exploration, and review probes. Fresh explicit approval should still be required for delegated edits, commits, PR creation, deploys, secrets, external side effects, or other high-blast-radius work.Without that split, the runtime pushes long-running teams toward either redundant user prompts or serial parent-thread work, even when the repo has already encoded a scoped standing delegation policy.
Suggested policy fix:
Allow
spawn_agentwhen either:If the activated workflow says to ask for permission first, Codex should ask once before spawning and then use sub-agents only at steps that actually call for them.
That keeps the guardrail against casual over-delegation, but avoids the current contradiction where a workflow can require a sub-agent while higher-priority tool policy says the model may not spawn one unless the user independently requests delegation.
In the meantime i simply use an orchestrator thread to spawn my new chats with explicit subagents authorizations among other things, it seems to work fine that way