Codex Subagents
Two dispatch mechanisms. Model choice and when-to-escalate live in CLAUDE.md.
Regular subagents: codex CLI
TASK_FILE=/path/to/task.md
codex exec -m gpt-5.6-sol -c model_reasoning_effort=medium -s workspace-write - < "$TASK_FILE"
- Prompt transport: write dynamic or untrusted task text to
TASK_FILE with the Write tool, then pass the file on stdin. Keep task text out of the Bash command so it cannot alter shell syntax.
- Sandbox:
-s workspace-write for implementation, -s read-only for investigation and review.
- Untrusted directories: outside a trusted git repo codex exits early — add
--skip-git-repo-check or git init the scratch dir.
- Parallel: one background Bash call per task. Parallel implementation tasks get separate worktrees so edits don't collide.
- Follow-up to the same worker:
codex exec resume --last -m gpt-5.6-sol -c model_reasoning_effort=medium "<feedback>" </dev/null — preserves that worker's context.
- Timeout: codex runs can exceed Bash's 10-minute default — pass an explicit timeout, or run in the background and poll for a report file.
In Workflows: Sonnet wrapper
Workflow/Agent model parameters only take Claude models. To use a GPT model in a workflow stage, spawn a thin Sonnet wrapper that shells out and relays:
agent(
`Delegate the task between the tags to Codex. Create a temporary file with
mktemp, save only the tagged task text to it with the Write tool, then pass the
file on stdin to this fixed command (substitute only the shell-quoted temp path):
codex exec -m gpt-5.6-sol -c model_reasoning_effort=medium -s read-only - < <temp-path>
Return Codex's output verbatim, adding no analysis.
<task>
${task}
</task>`,
{
model: "sonnet",
effort: "low",
label: "gpt-5.6-sol:review-auth",
schema: REPORT,
},
);
- Label with a
gpt-5.6-sol: prefix — the workflow UI shows the wrapper's Claude model, so the label is the only indication of the real worker.
schema on the wrapper gets structured output back from codex's free-text report.
isolation: 'worktree' for parallel implementation wrappers.
- Workflow token budgets only count Claude tokens; codex work is invisible to
budget.spent().
Orchestrating
- Decompose — each task gets acceptance criteria: observable, checkable outcomes (files changed, tests passing, behaviors demonstrated).
- Dispatch — simple, self-contained prompts. Codex is not Claude: it does only what it's told, so drop guardrail scaffolding. Review/investigation prompts end with: "If you find nothing, say so clearly and name what you inspected."
- Verify — check output against the acceptance criteria yourself (read the diff, run typecheck/tests). A worker's self-report is a claim, not evidence.
- Iterate —
resume with criteria-referenced feedback, ~3 rounds; then do it yourself or surface the blocker.
- Integrate — final assembly, commits, and user-facing summary stay with the orchestrator.
When a worker misbehaves, ask what went wrong and append the fix here.
1---2name: codex-subagents3description: Use when dispatching subagent work to GPT models (gpt-5.6-sol, gpt-5.5) via the Codex CLI, including inside Workflows.4---56# Codex Subagents78Two dispatch mechanisms. Model choice and when-to-escalate live in CLAUDE.md.910## Regular subagents: codex CLI1112```bash13TASK_FILE=/path/to/task.md14codex exec -m gpt-5.6-sol -c model_reasoning_effort=medium -s workspace-write - < "$TASK_FILE"15```1617- **Prompt transport**: write dynamic or untrusted task text to `TASK_FILE` with the Write tool, then pass the file on stdin. Keep task text out of the Bash command so it cannot alter shell syntax.18- **Sandbox**: `-s workspace-write` for implementation, `-s read-only` for investigation and review.19- **Untrusted directories**: outside a trusted git repo codex exits early — add `--skip-git-repo-check` or `git init` the scratch dir.20- **Parallel**: one background Bash call per task. Parallel implementation tasks get separate worktrees so edits don't collide.21- **Follow-up to the same worker**: `codex exec resume --last -m gpt-5.6-sol -c model_reasoning_effort=medium "<feedback>" </dev/null` — preserves that worker's context.22- **Timeout**: codex runs can exceed Bash's 10-minute default — pass an explicit timeout, or run in the background and poll for a report file.2324## In Workflows: Sonnet wrapper2526Workflow/Agent `model` parameters only take Claude models. To use a GPT model in a workflow stage, spawn a thin Sonnet wrapper that shells out and relays:2728```js29agent(30 `Delegate the task between the tags to Codex. Create a temporary file with31mktemp, save only the tagged task text to it with the Write tool, then pass the32file on stdin to this fixed command (substitute only the shell-quoted temp path):33codex exec -m gpt-5.6-sol -c model_reasoning_effort=medium -s read-only - < <temp-path>3435Return Codex's output verbatim, adding no analysis.3637<task>38${task}39</task>`,40 {41 model: "sonnet",42 effort: "low",43 label: "gpt-5.6-sol:review-auth",44 schema: REPORT,45 },46);47```4849- **Label with a `gpt-5.6-sol:` prefix** — the workflow UI shows the wrapper's Claude model, so the label is the only indication of the real worker.50- **`schema` on the wrapper** gets structured output back from codex's free-text report.51- **`isolation: 'worktree'`** for parallel implementation wrappers.52- Workflow token budgets only count Claude tokens; codex work is invisible to `budget.spent()`.5354## Orchestrating55561. **Decompose** — each task gets acceptance criteria: observable, checkable outcomes (files changed, tests passing, behaviors demonstrated).572. **Dispatch** — simple, self-contained prompts. Codex is not Claude: it does only what it's told, so drop guardrail scaffolding. Review/investigation prompts end with: "If you find nothing, say so clearly and name what you inspected."583. **Verify** — check output against the acceptance criteria yourself (read the diff, run typecheck/tests). A worker's self-report is a claim, not evidence.594. **Iterate** — `resume` with criteria-referenced feedback, ~3 rounds; then do it yourself or surface the blocker.605. **Integrate** — final assembly, commits, and user-facing summary stay with the orchestrator.6162When a worker misbehaves, ask what went wrong and append the fix here.