Codex subagents: spawn and configure custom agents
How Codex subagents work: how to start them, the built-in worker and explorer, custom agent TOML files, [agents] settings, and how approvals reach you.
Updated
Codex can split a task across subagents: helpers that each run in their own thread, with their own context, and hand a summary back to the main thread. You start them by asking ("spawn one agent per point"), or by putting that instruction in AGENTS.md or a skill. Codex ships three built-in agents (default, worker, explorer), and you can add your own as TOML files in ~/.codex/agents/ or .codex/agents/. What a subagent can’t do is change its own sandbox or approval policy. It always gets the parent’s.
As of November 2026, from OpenAI’s subagents and configuration reference docs. OpenAI made subagents available in Codex in March 2026 and changes these docs often, so its pages win if they disagree.
Every subagent is one more thread that can stop and ask. Coral shows every waiting Codex session in your Mac’s notch and on your iPhone, so the run doesn’t sit idle. Download Coral for free
How to start subagents in Codex
Current Codex releases have subagents on by default in the CLI, the desktop app and the IDE extension. Codex doesn’t spawn them on its own initiative. It spawns them when:
- you ask directly: “spawn two agents”, “delegate this in parallel”, “use one agent per point”;
- an instruction asks for it: an applicable
AGENTS.mdor skill tells Codex to delegate.
A good request says how to split the work, whether to wait for every agent, and what to return. OpenAI’s own example:
Review this branch with parallel subagents. Spawn one subagent for security risks,
one for test gaps, and one for maintainability. Wait for all three, then summarize
the findings by category with file references.
Where you watch them:
| Client | How to see and control subagents |
|---|---|
| CLI | /subagents lists the agent threads and switches between them while they run |
| Desktop app | Each subagent thread is linked from the main chat, with the summary it returned |
| IDE extension | A background-agent panel above the composer shows status, can stop all, and opens a thread |
In all three you can also just tell Codex to steer a running subagent, stop it, or close finished threads.
Use subagents for read-heavy work first: exploring a codebase, running tests, triaging logs, summarizing. OpenAI warns that parallel agents editing code at once “can create conflicts and increase coordination overhead.” Each subagent does its own model and tool work, so a subagent run uses more tokens than the same task done by one agent. See Codex usage limits for how that hits your plan.
Built-in agents and custom agents
Codex ships with three:
| Agent | For |
|---|---|
default | General-purpose fallback |
worker | Implementation and fixes |
explorer | Reading and mapping a codebase |
To add your own, create one TOML file per agent:
~/.codex/agents/for agents you want in every project;.codex/agents/in a repo for agents the whole team shares.
Three fields are required: name, description and developer_instructions. Codex goes by name, not the filename, and a custom agent named like a built-in one (say explorer) replaces it.
# .codex/agents/reviewer.toml
name = "reviewer"
description = "PR reviewer focused on correctness, security, and missing tests."
model_reasoning_effort = "high"
developer_instructions = """
Review code like an owner.
Do not edit files.
Lead with concrete findings and include reproduction steps when possible.
"""
Then ask for it by name: “Have reviewer check this branch against main.”
What a custom agent file can and can’t change:
| Can set | Can’t set (the parent’s value wins) |
|---|---|
model, model_reasoning_effort, model_reasoning_summary, model_verbosity | sandbox_mode, approval_policy |
Turn off features.shell_tool, features.apps, features.plugins, features.memories, features.request_permissions_tool | mcp_servers (configure them in the parent session) |
Turn off single skills with [[skills.config]], or bundled skills with skills.bundled.enabled = false | model_provider, service tier |
If you set no model, a subagent inherits the parent’s model and reasoning effort. OpenAI suggests gpt-6-luna for fast, narrow scans, and keeping the parent’s model and effort for everything else.
The [agents] settings in config.toml
Session-wide subagent settings live under [agents] in ~/.codex/config.toml or the project’s .codex/config.toml:
| Key | Default | What it does |
|---|---|---|
enabled | true | false turns multi-agent tools off |
max_concurrent_threads_per_session | Codex decides | Caps open subagent threads, not counting the main one. max_threads is the old name and still works |
default_subagent_model | the parent’s | Model for spawned agents |
default_subagent_reasoning_effort | the parent’s | Reasoning effort for spawned agents |
interrupt_message | true | Tells the model when an agent turn was interrupted |
[agents]
max_concurrent_threads_per_session = 6
default_subagent_reasoning_effort = "medium"
Model and effort are resolved in this order: what the spawn request asked for, then the [agents] default, then the parent’s value. A custom agent file that sets model or model_reasoning_effort overrides all three.
A subagent run is only as fast as your answer to its next approval. Coral puts Codex’s approval requests in your Mac’s notch with the full command, so you answer with one key from any app. Get Coral for free
Approvals and the sandbox: what subagents inherit
This is the part that surprises people.
- Subagents get the parent’s sandbox and approval policy, including anything you changed mid-session with
/permissionsor--yolo. Pick the permission mode before you ask Codex to delegate. - A “read-only” agent isn’t sandboxed read-only. Writing “Do not edit files” in
developer_instructionsis an instruction to the model, not a boundary. If the parent runsworkspace-write, so does your explorer. For a real read-only run, start the parent with-s read-only. The sandbox modes are in Codex sandbox and approval modes. - Prompts come from threads you’re not looking at. In the CLI, an approval request from any subagent thread pops up while you’re on the main thread. The overlay names the thread that asked; press
oto open that thread before you approve, reject or answer. - With no one to ask, the action fails. In
codex execand other non-interactive runs, or whenever Codex can’t show a fresh approval, an action that needs one fails and the error goes back to the parent.
So the more agents you run, the more prompts you’ll get. That’s the cost of any agent orchestration: the decisions come back up to whoever started it. And because Codex waits for every requested result before it writes the combined answer, one unanswered prompt holds up the whole run. The same goes for a Codex /goal: it keeps your approval policy, so an overnight goal stops at the first prompt nobody answers.
Codex subagents vs Claude Code subagents
| Codex | Claude Code | |
|---|---|---|
| Where they live | ~/.codex/agents/, .codex/agents/ | ~/.claude/agents/, .claude/agents/ |
| Format | TOML, one agent per file | Markdown with YAML frontmatter |
| Required fields | name, description, developer_instructions | name, description |
| Built-in | default, worker, explorer | Explore, Plan, general-purpose, and a few helpers |
| Started by | Your request, or AGENTS.md and skill instructions | Claude on its own when a description fits, or your request |
| Own permission mode | No, always the parent’s | permissionMode in frontmatter, ignored when the parent is in bypass, accept-edits, auto or plan mode |
| Limit | max_concurrent_threads_per_session (Codex picks the default) | 20 running at once by default (CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS) |
| Manage them | /subagents | /agents |
The Claude Code column is from Anthropic’s subagents docs. If you use both, the same split works: one narrow reviewer, one explorer on a cheaper model, and the main thread making decisions. For the rest of the comparison, see Codex vs Claude Code. For running whole separate sessions in parallel instead of subagents inside one, see Run several agents at once.
Where Coral fits
Subagents make Codex faster until one of them needs you. Coral installs Codex hooks for approval requests and shows each waiting Codex session (the CLI or the app) next to Claude Code, Copilot, OpenCode and Grok in your Mac’s notch, with whoever has waited longest first:
- Answer with one key. Press 1, 2 or 3 with the full command in front of you. ⌘Z takes it back within two seconds.
- From any app. A card drops from the notch when Codex asks; ⌃⌥1 answers without leaving your editor.
- Away from your Mac. Alerts on your iPhone are Free; answering from the phone straight to the agent is Pro.
You keep the sandbox on and stop losing the parallel speed-up to an approval nobody saw.
Questions
Does Codex have subagents?
Yes. Codex runs subagent workflows in the CLI, the desktop app and the IDE extension, and current releases enable them by default. Ask Codex to spawn agents or delegate work in parallel, and it collects their results into one answer.
How do I create a custom subagent in Codex?
Add a TOML file to ~/.codex/agents/ (personal) or .codex/agents/ (project) with name, description and developer_instructions. You can also set model and model_reasoning_effort. Then ask Codex to use the agent by its name.
How many subagents can Codex run at once?
As many as agents.max_concurrent_threads_per_session allows, not counting the main thread. If you don’t set it, Codex picks the default. Older configs can use agents.max_threads, which still works.
Can a Codex subagent have its own sandbox or approval mode?
No. Subagents inherit the parent session’s sandbox and approval settings, and sandbox_mode or approval_policy in a custom agent file is ignored. Set them on the parent session before you delegate.
Why does Codex ask for approval from a subagent thread?
Each subagent runs commands under the same approval policy as the parent, so anything that would prompt in the main thread prompts in a subagent too. In the CLI the overlay shows which thread asked, and o opens that thread before you answer.
Do Codex subagents use more of my usage limit?
Yes. Each subagent does its own model and tool work, so a subagent run uses more tokens than the same task done by one agent. Put fast, narrow agents on a smaller model like gpt-6-luna to spend less.