agent-configuration/subagents.md +19 −97
114For most tasks in Codex, start with 114For most tasks in Codex, start with
115 `gpt-5.6`. Use 115 `gpt-5.6`. Use
116 `gpt-5.6-terra` when you want116 `gpt-5.6-terra` when you want
117117 a faster, lower-cost option for lighter subagent work. If you have ChatGPT Pro a faster, lower-cost option for lighter subagent work.
118 and want near-instant text-only iteration, `gpt-5.3-codex-spark` remains
119 available in research preview.
120 118
121### Model choice119### Model choice
122 120
123- **`gpt-5.6`**: Start here for demanding agents. It's strongest for ambiguous, multi-step work that needs planning, tool use, validation, and follow-through across a larger context.121- **`gpt-5.6`**: Start here for demanding agents. It's strongest for ambiguous, multi-step work that needs planning, tool use, validation, and follow-through across a larger context.
124- **`gpt-5.4`**: Use this when a workflow is pinned to GPT-5.4. It combines strong coding, reasoning, tool use, and broader workflows.122- **`gpt-5.4`**: Use this when a workflow is pinned to GPT-5.4. It combines strong coding, reasoning, tool use, and broader workflows.
125- **`gpt-5.6-terra`**: Use for agents that favor speed and efficiency over depth, such as exploration, read-heavy scans, large-file review, or processing supporting documents. It works well for parallel workers that return distilled results to the main agent.123- **`gpt-5.6-terra`**: Use for agents that favor speed and efficiency over depth, such as exploration, read-heavy scans, large-file review, or processing supporting documents. It works well for parallel workers that return distilled results to the main agent.
126- **`gpt-5.3-codex-spark`**: If you have ChatGPT Pro, use this research preview model for near-instant, text-only iteration when latency matters more than broader capability.
127 124
128### Reasoning effort (`model_reasoning_effort`)125### Reasoning effort (`model_reasoning_effort`)
129 126
134- **`high`**: Use when an agent needs to trace complex logic, check assumptions, or work through edge cases (for example, reviewer or security-focused agents).131- **`high`**: Use when an agent needs to trace complex logic, check assumptions, or work through edge cases (for example, reviewer or security-focused agents).
135- **`medium`**: A balanced default for most agents.132- **`medium`**: A balanced default for most agents.
136- **`low`**: Use when the task is straightforward and speed matters most.133- **`low`**: Use when the task is straightforward and speed matters most.
137- **`minimal`** and **`none`**: Use when the selected model supports these
138 lower-latency levels and the task needs little or no reasoning.
139 134
140Higher reasoning effort increases response time and token usage, but it can improve quality for complex work. For details, see [Models](https://learn.chatgpt.com/docs/models), [Config basics](https://learn.chatgpt.com/docs/config-file/config-basic), and [Configuration Reference](https://learn.chatgpt.com/docs/config-file/config-reference).135Higher reasoning effort increases response time and token usage, but it can improve quality for complex work. For details, see [Models](https://learn.chatgpt.com/docs/models), [Config basics](https://learn.chatgpt.com/docs/config-file/config-basic), and [Configuration Reference](https://learn.chatgpt.com/docs/config-file/config-reference).
141 136
142<code>agents.max_depth</code> controls nesting and defaults to <code>1</code>,
143 which lets the root thread spawn direct children but prevents those children
144 from spawning deeper descendants.
145
146 137
147 138
148## Orchestration and thread controls139## Orchestration and thread controls
252- `description`243- `description`
253- `developer_instructions`244- `developer_instructions`
254 245
255246Optional fields such as `nickname_candidates`, `model`,If a custom agent file sets `model` or `model_reasoning_effort`, the value in
256247`model_reasoning_effort`, `sandbox_mode`, `mcp_servers`, and `skills.config`the file takes precedence. Otherwise, Codex resolves each setting independently:
257248inherit from the parent session when you omit them.an explicit spawn value, then the corresponding `[agents]` default, then the
249parent's value. If a spawn selects a different model and neither an explicit nor
250configured effort is present, Codex uses that model's default effort. Other
251session settings, such as `sandbox_mode`, `mcp_servers`, and `skills.config`,
252inherit from the parent when the custom agent file omits them.
258 253
259### Global settings254### Global settings
260 255
261Global subagent settings still live under `[agents]` in your [configuration](https://learn.chatgpt.com/docs/config-file/config-basic#configuration-precedence).256Global subagent settings still live under `[agents]` in your [configuration](https://learn.chatgpt.com/docs/config-file/config-basic#configuration-precedence).
262 257
263| Field | Type | Required | Purpose |258| Field | Type | Required | Purpose |
264259| -------------------------------- | ------- | :------: | ----------------------------------------------------------------- || ------------------------------------------- | ------- | :------: | ------------------------------------------------------------------- |
265260| `agents.max_threads` | number | No | Concurrent open agent thread cap. || `agents.enabled` | boolean | No | Enable or disable multi-agent tools. |
266261| `agents.max_depth` | number | No | Spawned agent nesting depth (root session starts at 0). || `agents.max_concurrent_threads_per_session` | number | No | Cap concurrently open spawned-agent threads, excluding the primary. |
267262| `agents.job_max_runtime_seconds` | number | No | Default timeout per worker for `spawn_agents_on_csv` jobs. || `agents.default_subagent_model` | string | No | Set the default model for spawned agents. |
263| `agents.default_subagent_reasoning_effort` | string | No | Set the default reasoning effort for spawned agents. |
268| `agents.interrupt_message` | boolean | No | Record a model-visible message when an agent turn is interrupted. |264| `agents.interrupt_message` | boolean | No | Record a model-visible message when an agent turn is interrupted. |
269 265
270**Notes:**266**Notes:**
271 267
272268- `agents.max_threads` defaults to `6` when you leave it unset.- `agents.enabled` defaults to `true`. Set it to `false` to disable multi-agent tools.
273269- `agents.max_depth` defaults to `1`, which lets the root thread spawn direct children but prevents those children from spawning deeper descendants. Keep the default unless you specifically need recursive delegation. Raising this value can turn broad delegation instructions into repeated fan-out, which increases token usage, latency, and local resource consumption. `agents.max_threads` still caps concurrent open threads, but it doesn't remove the cost and predictability risks of deeper recursion.- When you leave `agents.max_concurrent_threads_per_session` unset, Codex chooses the default. Existing configurations can keep using `agents.max_threads` as a legacy alias.
274270- `agents.job_max_runtime_seconds` is optional. When you leave it unset, `spawn_agents_on_csv` falls back to its per-call default timeout of 1800 seconds per worker.- Explicit spawn values override `agents.default_subagent_model` and `agents.default_subagent_reasoning_effort`.
275- `agents.interrupt_message` defaults to `true`. Set it to `false` to omit the model-visible interruption message from the agent's context.271- `agents.interrupt_message` defaults to `true`. Set it to `false` to omit the model-visible interruption message from the agent's context.
276- If a custom agent name matches a built-in agent such as `explorer`, your custom agent takes precedence.272- If a custom agent name matches a built-in agent such as `explorer`, your custom agent takes precedence.
277 273
278### Custom agent file schema274### Custom agent file schema
279 275
280| Field | Type | Required | Purpose |276| Field | Type | Required | Purpose |
281277| ------------------------ | -------- | :------: | --------------------------------------------------------------- || ------------------------ | ------ | :------: | --------------------------------------------------------------- |
282| `name` | string | Yes | Agent name Codex uses when spawning or referring to this agent. |278| `name` | string | Yes | Agent name Codex uses when spawning or referring to this agent. |
283| `description` | string | Yes | Human-facing guidance for when Codex should use this agent. |279| `description` | string | Yes | Human-facing guidance for when Codex should use this agent. |
284| `developer_instructions` | string | Yes | Core instructions that define the agent's behavior. |280| `developer_instructions` | string | Yes | Core instructions that define the agent's behavior. |
285| `nickname_candidates` | string[] | No | Optional pool of display nicknames for spawned agents. |
286 281
287You can also include other supported `config.toml` keys in a custom agent file, such as `model`, `model_reasoning_effort`, `sandbox_mode`, `mcp_servers`, and `skills.config`.282You can also include other supported `config.toml` keys in a custom agent file, such as `model`, `model_reasoning_effort`, `sandbox_mode`, `mcp_servers`, and `skills.config`.
288 283
290the agent name is the simplest convention, but the `name` field is the source285the agent name is the simplest convention, but the `name` field is the source
291of truth.286of truth.
292 287
293### Display nicknames
294
295Use `nickname_candidates` when you want Codex to assign more readable display
296names to spawned agents. This is especially helpful when you run many
297instances of the same custom agent and want the UI to show distinct labels
298instead of repeating the same agent name.
299
300Nicknames are presentation-only. Codex still identifies and spawns the agent by
301its `name`.
302
303Nickname candidates must be a non-empty list of unique names. Each nickname can
304use ASCII letters, digits, spaces, hyphens, and underscores.
305
306Example:
307
308```toml
309name = "reviewer"
310description = "PR reviewer focused on correctness, security, and missing tests."
311developer_instructions = """
312Review code like an owner.
313Prioritize correctness, security, behavior regressions, and missing test coverage.
314"""
315nickname_candidates = ["Atlas", "Delta", "Echo"]
316```
317
318In practice, the ChatGPT desktop app, Codex CLI, and IDE extension can show the
319nicknames where agent activity appears, while the underlying agent type stays
320`reviewer`.
321
322### Example custom agents288### Example custom agents
323 289
324The best custom agents are narrow and opinionated. Give each one clear job, a290The best custom agents are narrow and opinionated. Give each one clear job, a
337 303
338```toml304```toml
339[agents]305[agents]
340306max_threads = 6max_concurrent_threads_per_session = 8
341max_depth = 1
342```307```
343 308
344`.codex/agents/pr-explorer.toml`:309`.codex/agents/pr-explorer.toml`:
395Review this branch against main. Have pr_explorer map the affected code paths, reviewer find real risks, and docs_researcher verify the framework APIs that the patch relies on.360Review this branch against main. Have pr_explorer map the affected code paths, reviewer find real risks, and docs_researcher verify the framework APIs that the patch relies on.
396```361```
397 362
398## Process CSV batches with subagents (experimental)
399
400This workflow is experimental and may change as subagent support evolves.
401Use `spawn_agents_on_csv` when you have many similar tasks that map to one row per work item. Codex reads the CSV, spawns one worker subagent per row, waits for the full batch to finish, and exports the combined results to CSV.
402
403This works well for repeated audits such as:
404
405- reviewing one file, package, or service per row
406- checking a list of incidents, PRs, or migration targets
407- generating structured summaries for many similar inputs
408
409The tool accepts:
410
411- `csv_path` for the source CSV
412- `instruction` for the worker prompt template, using `{column_name}` placeholders
413- `id_column` when you want stable item ids from a specific column
414- `output_schema` when each worker should return a JSON object with a fixed shape
415- `output_csv_path`, `max_concurrency`, and `max_runtime_seconds` for job control
416
417Each worker must call `report_agent_job_result` exactly once. If a worker exits without reporting a result, Codex marks that row with an error in the exported CSV.
418
419Example prompt:
420
421```text
422Create /tmp/components.csv with columns path,owner and one row per frontend component.
423
424Then call spawn_agents_on_csv with:
425- csv_path: /tmp/components.csv
426- id_column: path
427- instruction: "Review {path} owned by {owner}. Return JSON with keys path, risk, summary, and follow_up via report_agent_job_result."
428- output_csv_path: /tmp/components-review.csv
429- output_schema: an object with required string fields path, risk, summary, and follow_up
430```
431
432When you run this through `codex exec`, Codex shows a single-line progress update on `stderr` while the batch is running. The exported CSV includes the original row data plus metadata such as `job_id`, `item_id`, `status`, `last_error`, and `result_json`.
433
434Related runtime settings:
435
436- `agents.max_threads` caps how many agent threads can stay open concurrently.
437- `agents.job_max_runtime_seconds` sets the default per-worker timeout for CSV fan-out jobs. A per-call `max_runtime_seconds` override takes precedence.
438- `sqlite_home` controls where Codex stores the SQLite-backed state used for agent jobs and their exported results.
439
440#### Example 2: Frontend integration debugging363#### Example 2: Frontend integration debugging
441 364
442This pattern is useful for UI regressions, flaky browser flows, or integration bugs that cross application code and the running product.365This pattern is useful for UI regressions, flaky browser flows, or integration bugs that cross application code and the running product.
445 368
446```toml369```toml
447[agents]370[agents]
448371max_threads = 6max_concurrent_threads_per_session = 6
449max_depth = 1
450```372```
451 373
452`.codex/agents/code-mapper.toml`:374`.codex/agents/code-mapper.toml`: