Codex Subagent Orchestration
Use subagents only when they produce a concrete quality gain: independent review, parallel research, specialist analysis, or bounded implementation.
Workflow
- Define the outcome, risk level, decision owner, and whether subagents are needed at all.
- Split work by responsibility, not by vague persona. Prefer narrow roles such as explorer, reviewer, security reviewer, visual QA, or migration planner.
- Give each subagent a context contract: artifact paths, source URLs, exact question, expected output, forbidden assumptions, and validation command.
- Limit tools, filesystem access, network access, sandbox mode, and production scope to the smallest useful surface.
- Set token, time, depth, and concurrency limits before spawning work.
- Require every subagent to separate facts, assumptions, risks, and recommended actions.
- Merge outputs in the parent thread; do not let subagents make irreversible, paid, production, email, billing, DNS, trading, legal, medical, hiring, or compliance decisions.
- Add regression coverage when the workflow will be reused: eval fixture, checklist, prompt contract, or automation memory entry.
Custom Agent Checklist
nameis stable, short, and matches the job.descriptionstates when to use the agent and when not to.developer_instructionsdefine responsibilities, output format, evidence standard, and escalation rules.- Optional
nickname_candidatesare presentation-only. - Optional model, reasoning, sandbox, MCP, and skills settings are narrower than the parent session unless there is a documented reason.
- The agent cannot recursively delegate unless recursion is explicitly required and capped.
Useful Patterns
- Explorer plus reviewer for unfamiliar repositories.
- Parallel source researchers for GitHub/docs comparison.
- Security or privacy reviewer for high-impact changes.
- Visual QA reviewer after frontend implementation.
- Migration planner plus test architect for risky refactors.
Output Shape
Return:
- subagent map with purpose and inputs;
- tool and sandbox limits;
- merge protocol;
- validation gates;
- rejected agent roles and why.
Guardrails
- Do not spawn agents to avoid reading the source yourself.
- Do not leak secrets, raw private logs, credentials, or personal data into prompts.
- Do not use broad "do everything" agents.
- Do not trust subagent findings without parent verification against source artifacts.