GuidesHosting choices

Codex subagents: how they spawn, custom agents and limits

Codex CLI 0.173.0 subagents: on by default, when Codex spawns them, the [agents] keys, custom agent TOML files, sandbox inheritance and plan cost.

December 2, 2026The Everpod team
The short answer

Codex CLI’s subagents are on by default, with nothing to switch on: the main agent calls a spawn_agent tool, each subagent works its task in a thread of its own, and the parent waits for their results. As of Codex 0.173.0 (December 2, 2026) the local CLI spawns them only when you ask, or when an AGENTS.md file or a skill tells it to. Up to three run at once by default on the current models; raise or lower that with max_concurrent_threads_per_session under [agents] in config.toml, or set enabled = false there to turn them off. Custom agents are TOML files in .codex/agents/ or ~/.codex/agents/ with a name, a description and instructions, and they can set their own model and reasoning effort but never their own sandbox or approval policy: every subagent runs under the parent’s.

How Codex starts one

Delegation is a tool the model calls. In the 0.173.0 source, the main agent gets spawn_agent, wait_agent and interrupt_agent, with tools beside them for sending a running subagent a message, giving it a follow-up task and listing the agents. There are two generations of this system in the code, and which one a session uses is decided by the model: in Codex’s model catalogue every GPT-6 model, Luna included, is marked for the newer one. Some older models are marked for the first, and a model marked for neither gets the first through the features.multi_agent flag, which defaults to true.

What Codex will not do in the terminal is delegate on a hunch. OpenAI’s subagents page is explicit: “Current local Codex releases spawn agents after a direct request or applicable project or skill instruction.” The Ultra reasoning level that delegates proactively is described there for ChatGPT, not the CLI. So a prompt that wants parallel work says how to split it, whether to wait, and what to bring back:

Spawn three agents, one per service in services/, to find every place that reads DATABASE_URL. Wait for all three, then give me one list with file and line.
Copied

A standing instruction in AGENTS.md (“for any review, spawn one agent per changed package”) or in a skill does the same without the prompt.

One thing differs from what the word suggests. A new subagent does not start blank: the spawn tool’s fork_turns parameter “Defaults to all,” so the child inherits the parent’s whole conversation unless the parent passes none. Your earlier instructions therefore reach it; so does everything that filled your context, which is part of what it costs. Subagents also work in the same folder as the parent, so two of them told to edit the same files will collide. The built-in worker role’s description tells the main agent to assign each worker the files it owns and to tell workers they are not alone in the codebase, which is the right shape for any prompt that splits edits.

The [agents] settings

Everything global sits in one table of config.toml, in ~/.codex/ or a trusted project’s .codex/:

[agents]
max_concurrent_threads_per_session = 2
default_subagent_model = "gpt-6-luna"
default_subagent_reasoning_effort = "medium"
Copied
KeyDefaultWhat it does
enabled
trueTurns the multi-agent tools on or off. An enabled features.multi_agent_v2 overrides it
max_concurrent_threads_per_session
3 on current models (6 on the older system)Subagents open at once, not counting the main thread; 0 is refused. max_threads is its old name
default_subagent_model
Unset: the parent’s modelModel for a subagent when the spawn call names none
default_subagent_reasoning_effort
Unset: the parent’s effort, or the chosen model’s own default when a subagent is given a model and no effortThe same, for reasoning effort
max_depth
1How deep subagents may nest, for the older system only; the current one ignores it
interrupt_message
trueTells the model when a subagent’s turn was interrupted

OpenAI’s docs say only that when the cap is unset, “Codex chooses the default.” The source is specific: the current system allows four threads per session including the main one, so three subagents, and a value you set is the number of subagents, with one added for the main thread. OpenAI’s own examples set it to 6 and 8. To switch subagents off entirely:

[agents]
enabled = false
Copied

Defining a custom agent

A custom agent is a TOML file in ~/.codex/agents/ (yours, in every project) or .codex/agents/ (this project). Codex reads every .toml file in those folders, subfolders included, and three fields are required: name, description and developer_instructions. A reviewer on the main model at medium effort, saved as .codex/agents/reviewer.toml:

name = "reviewer"
description = "Reviews a diff for correctness, security and missing tests. Use for any code review."
model = "gpt-6.2-sol"
model_reasoning_effort = "medium"
developer_instructions = """
Review the changes you are pointed at. Do not edit files.
Report each problem with its file and line, why it matters, and the smallest fix.
"""
Copied

The name field, not the file’s name, is what Codex calls the agent by, so pr-explorer.toml can define pr_explorer. The description is what Codex reads when it decides which agent type fits a task, so write it as when to use the agent. Beyond the model and effort, a file may set model_reasoning_summary and model_verbosity, and it can take capabilities away by setting feature keys to false under [features]: shell_tool, apps, plugins, memories and request_permissions_tool. A project’s agent replaces a personal one of the same name. The built-in types are default, worker (for execution work) and explorer (for specific questions about the codebase).

You can also declare a role in config.toml itself, as [agents.reviewer] with a description and a config_file pointing at its settings, a path read relative to the config file that declares it. Two things in the source explain the custom agent that seems to be ignored. The spawn tool tells the model to leave the agent type out “unless explicitly asked,” so name the agent in your prompt (“spawn the reviewer agent on this diff”). And a role without a description is not loaded: Codex reports that it “must define a description.”

Sandbox and approvals come from the parent

This is the part most often got wrong. A subagent runs under the sandbox and approval policy of the turn that spawned it, and a custom agent file cannot change either. The docs list sandbox_mode, approval_policy, model_provider and mcp_servers as keys that “don’t override the parent configuration when placed in a custom agent file,” and the source’s own comment on roles reads: “Roles may customize the child or reduce its capabilities, but never replace the parent session’s authority.” A line such as sandbox_mode = "read-only" in an agent file is ignored. The page says it plainly:

Custom agent instructions can ask an agent to avoid edits, but they don’t create a separate read-only sandbox.
Copied

So the sandbox you choose for the session is the one every subagent gets: to have read-only reviewers, start the session read-only. The modes and the flags that set them are in Codex’s sandbox modes. What an agent file can do is take tools away, such as setting shell_tool to false. MCP servers, the model provider and the service tier are the parent’s too. Approvals follow the same line: in a non-interactive run, an action that would need a new approval fails, and Codex returns the error to the parent agent.

Watching them

In the terminal, /subagents switches between this session’s subagents, so you can read one thread while the others run. The main agent has tools to message or interrupt a subagent, so ask it in plain words to steer or stop one. /agents, with an s and no “sub”, is something else: it opens Codex’s agent command center.

In codex exec, subagents work too, and with --json each call to the tools arrives as an item of type collab_tool_call. Its fields are the tool (spawn_agent, send_input, wait or close_agent), the sender_thread_id and receiver_thread_ids, the prompt sent, and agents_states, the last known status of each subagent: pending_init, running, interrupted, completed, errored, shutdown or not_found. A script that wants to know whether a fan-out finished cleanly reads those states rather than the final message.

What subagents cost on a ChatGPT plan

There is no separate allowance. Subagents draw on the same five-hour and weekly limits as everything else Codex does on your plan, and OpenAI’s docs warn that “subagent workflows consume more tokens than comparable single-agent runs.” Two settings above make it worse or better. Each subagent inherits the parent’s whole conversation by default, so three subagents spawned late in a long session each start by reading all of it. And each runs on the parent’s model unless told otherwise.

The model is the larger lever. OpenAI’s pricing page, as of December 2026, estimates 17 to 180 local messages per five hours on Plus with GPT-6.2 Sol and 350 to 3,000 with GPT-6 Luna, and prices them at 50 and 2.5 credits per million input tokens. Luna is also the model OpenAI suggests for fast, narrow subagent work, so default_subagent_model = "gpt-6-luna" is the setting that stretches a plan furthest, with a custom agent on GPT-6.2 Sol for the work that needs the stronger model. How the models compare is in Codex’s model list.

Codex subagents and Claude Code’s, side by side

Codex CLI 0.173.0Claude Code
Who decides to delegate
You, AGENTS.md or a skillClaude too, when a task matches a subagent’s description
Definition
TOML in .codex/agents/ or ~/.codex/agents/Markdown with YAML frontmatter in .claude/agents/ or ~/.claude/agents/
What it starts with
The parent’s whole conversation, unless the parent says otherwiseA fresh context; only a fork inherits the conversation
Own model and effort
YesYes
Own permissions
No: the parent’s sandbox and approvalsYes: its own permission mode and a tool allowlist or denylist
At once, by default
3At least 20
Nesting
Limited to one level on the older system; not documented for the current oneUp to three levels below the main conversation
Cost
The plan’s shared limitsThe plan’s shared limits

The two rows that change how you use them are the first and the permissions. Claude Code reaches for a subagent unasked and can lock one down to a few read-only tools; Codex waits to be told and gives every subagent the parent’s authority, narrowed only by the features you switch off. Claude Code’s side, with a measured comparison of the same search with and without a subagent, is in Claude Code subagents.

Run Codex on an always-on developer pod.

A developer pod is a permanent cloud computer (VPS), set up and secured for you, with your pick of Claude Code, Codex, OpenCode, Pi, Hermes and OpenClaw installed. Run more agents at once than your laptop can hold, and keep them working when it’s closed. From $24 a month, built in about ten minutes.