OpenAI Codex Now Lets AI Agents Spawn Their Own Subagents

OpenAI Codex subagents parallel AI coding agents

OpenAI has added subagent support to Codex, its AI coding assistant. The feature allows the main AI agent to spawn specialized child agents that work in parallel, each with its own instructions, model settings, and tool context. The results are then collected and merged into a single response.

How Subagents Work

Codex handles all orchestration: spawning new subagents, routing follow-up instructions, waiting for results, and closing agent threads. Each subagent runs independently with its own context window, which prevents what OpenAI calls "context pollution" — where cramming too many different tasks into one context degrades output quality.

The feature is available in both the Codex app and Codex CLI, with IDE extension support coming soon. Importantly, Codex only spawns subagents when you explicitly ask it to — it does not automatically delegate tasks.

Watch the Demo

Practical Use Cases

OpenAI suggests several scenarios where subagents are useful:

  • Code review: Spawn one agent per review criterion (security, code quality, bugs, race conditions, test flakiness, maintainability) and get a consolidated summary
  • Codebase exploration: Multiple agents explore different parts of a codebase simultaneously
  • Multi-step feature implementation: Break a feature plan into parallel tasks handled by different agents

Built-in and Custom Agents

Codex ships with three built-in agent types: a general-purpose "default" agent, an execution-focused "worker" agent for implementation and fixes, and a read-heavy "explorer" agent for codebase exploration. Developers can also define custom agents using TOML configuration files with specific model configurations, instructions, and tool access.

The system defaults to a maximum of 6 concurrent agent threads and 1 level of nesting depth (agents can spawn children, but children cannot spawn grandchildren).

The Bottom Line

This is a direct response to Anthropic's Claude Code, which has had subagent capabilities for months. The approach is sound — parallel agents with isolated contexts genuinely solve the context pollution problem that plagues long coding sessions. But the token consumption warning is worth noting: subagent workflows burn through tokens significantly faster than single-agent runs. For developers on metered plans, a six-agent code review could get expensive fast. The custom agent configuration via TOML files is a nice touch for power users, though most developers will likely stick with the built-in options. Available now for all Codex users.