Does Codex have subagents?
Yes. Codex subagents are delegated agents that a parent Codex chat starts for a specific task. The parent coordinates their work and combines their findings into one response. Current releases enable subagent workflows by default. Ask for delegation directly, or use applicableAGENTS.md or skill instructions that request it. Native delegation works without AMS. See the official OpenAI subagent documentation.
Inspect the delegated threads from subagent activity in the app, or use /subagents in an interactive CLI session. Ask the parent to steer or stop a running subagent when its scope needs to change.
Prerequisites
- A working, signed-in Codex app or CLI with access to the repository.
- Your repository’s instructions, including
AGENTS.md, and its normal validation commands. - Git for worktrees. The small example below uses a POSIX shell and Node.js 22 or newer, with no third-party packages.
- For the optional AMS exercise, an authenticated AMS CLI and two independent tasks in the same workspace.
Choose a Codex multi-agent workflow
Prefer a single chat when each step depends on the previous result, or when the task is too small to justify coordination. Use parallel work when you can give each agent a clear question, allowed paths and a result that can be checked independently.
A worktree is a Git checkout, not an agent or a parent-child relationship. A new independent chat is a separate conversation. Reading the same repository does not give it another chat’s private transcript. OpenAI describes these boundaries in Projects and chats. Provide the goal, contract, relevant paths and expected evidence explicitly. See sharing context between coding agents for longer handoffs.
Try a small delegated task
This exercise divides a label-normalization function and its tests between two subagents. The behavior is specified up front, so neither has to wait for the other to design the interface. The example is deliberately small. A single agent would usually finish this function faster; its purpose is to make ownership and verification easy to inspect before applying the pattern to larger work.1. Create a disposable project
Run these commands in a directory wherecodex-parallel-demo does not already exist:
2. Give each subagent one file
Send this to the parent chat:A subagent is not automatically a separate Git worktree. Plan for shared files unless you have explicitly arranged separate checkouts. File ownership in a prompt is a coordination rule; it is not a filesystem permission boundary.
3. Review and verify the combined result
After both agents finish, the parent should inspect the actual files. A plausible implementation is:" Hello World ", "Hello World\tAgain\nToday", and "Hello, World!". The expected results are "hello-world", "hello-world-again-today", and "hello,-world!".
Run the verification yourself from the project directory:
0, four passing tests, no failures, and changes confined to the two assigned files. A parent summary that says “done” without the files and test result is not enough.
For a second review pass, ask:
Run independent Codex chats in worktrees
Use independent chats for changes with separate lifetimes: for example, an API fix and a documentation update that you want to review separately. A branch name alone does not isolate files inside one checkout. In the app, start a new chat in Worktree mode and choose its starting branch. Repeat for the second task. Confirm that each chat reports a different working directory before allowing parallel edits. App-created worktrees normally start with a detachedHEAD; create a task branch when your repository’s workflow requires one. See OpenAI’s worktree guide.
For CLI sessions, first prepare separate worktrees using your project’s approved workflow. Open one terminal in each assigned checkout:
/agents opens the chat command center. /subagents selects a delegated thread within the current session. See OpenAI’s developer commands.
Before editing, have each task run:
Add an optional shared AMS conversation
Native delegation already returns findings to its parent. Use AMS when independent tasks need a place to discuss an interface, record ownership or hand work to a task in another coding tool. For an implementation and review involving Claude Code, use the Claude Code and Codex guide.Connect the two tasks
Complete the quickstart and deliberately enable the repository or worktrees you want to coordinate, following folder and repository workspace setup. An installed integration or inherited profile does not activate an unconfigured folder. In each agent’s own shell, start with the offline activation check:enabled: true. If it reports false, automatic coordination stays off until you explicitly enable the intended workspace and scope. If the check fails or is unsupported, resolve that error or update the CLI through your approved path; do not fall back to another profile or unguarded commands.
In an enabled folder, guard the coordination commands:
ams --require-workspace channels:
(more available). Each task keeps its own progress. If the installed CLI does not recognize --resume, update through your approved CLI update path.
Verify a useful handoff
Give task A a specific request to send:ams --require-workspace messages --resume, inspect the relevant code, and reply with its finding or acknowledgement. Return to task A and have it read again. An effective response identifies the path, the behavior and the next action; a bare “received” does not resolve an interface question.
This is an illustrative handoff. In a real project, include the worktree or revision and actual test evidence. Wait for acknowledgement before a change that depends on the other owner accepting a new contract.
AMS stores shared messages. It does not automatically copy private session history or wake and resume every agent. A successful send proves storage, not that the recipient read or accepted it. Continue an inactive task through its host, then have it read the channel.
ams --require-workspace message watch --resume follows messages while its process stays alive and the host surfaces its output. Read again when a task resumes and before it finishes. For reusable coordination instructions or an MCP alternative, see Connect Codex to AMS.
Keep the boundaries explicit
- Shared files: give shared manifests, lockfiles, migrations and generated files one owner. Worktrees prevent immediate overwrites, but overlapping changes can still conflict during integration. They share Git refs: do not move or delete another task’s branch.
- Permissions: subagents inherit parent sandbox and approval settings. “Review only” is an instruction, not a separate enforced sandbox. Independent chats need their own appropriate permission settings.
- Context: put durable project rules in
AGENTS.md; give each task the decisions and evidence it needs. A shared directory or AMS membership does not make all conversation history available. - Test resources: separate checkouts can still use the same port, database, external account or fixture. Assign isolated resources or serialize those tests. Keep the detailed setup in the worktree guide.
- Capacity: parallel agents consume additional model usage and can compete for CPU, memory and service limits. Start with a few independent tasks; more agents do not guarantee faster completion.
Troubleshoot parallel work
Sources and related guides
- OpenAI: subagents — delegation, client support, permissions and usage.
- OpenAI: developer commands — interactive thread controls.
- OpenAI: worktrees — independent checkouts and the app workflow.
- OpenAI: project instructions with AGENTS.md — persistent repository guidance.
- Run multiple Claude Code agents — the corresponding Claude workflow.