How to run subagents in Codex

By (@mandela) · · AI Agents

How to run subagents in Codex - image 1

Codex just dropped subagents.
Here's everything you need to know.

๐—ช๐—ต๐—ฎ๐˜ ๐—ฎ๐—ฟ๐—ฒ ๐˜€๐˜‚๐—ฏ๐—ฎ๐—ด๐—ฒ๐—ป๐˜๐˜€?
When you use Codex today, everything runs in one single thread.
You give it a task. It explores your codebase. It writes code. It runs tests. All together.
The problem is that over time, the thread fills up with noise โ€” exploration notes, test logs, stack traces. Codex starts losing context. Performance drops.
Subagents fix this.
Instead of one agent doing everything, Codex now spawns multiple specialized agents that run in parallel. Each one handles a specific task. When they're done, they report back to the main agent with clean summaries.
One brain coordinating a team.

๐—›๐—ผ๐˜„ ๐˜๐—ผ ๐˜‚๐˜€๐—ฒ ๐˜๐—ต๐—ฒ๐—บ
No complex setup. You just tell Codex what you want.
Example prompt:
"Review this branch with parallel subagents. Spawn one for security risks, one for test gaps, one for maintainability. Wait for all three, then summarize."
Codex spawns 3 agents. They work simultaneously. Each explores a different angle. The main agent combines everything into one clean output.

๐—–๐—ต๐—ผ๐—ผ๐˜€๐—ถ๐—ป๐—ด ๐˜๐—ต๐—ฒ ๐—ฟ๐—ถ๐—ด๐—ต๐˜ ๐—บ๐—ผ๐—ฑ๐—ฒ๐—น ๐—ณ๐—ผ๐—ฟ ๐—ฒ๐—ฎ๐—ฐ๐—ต ๐—ฎ๐—ด๐—ฒ๐—ป๐˜
This is where it gets interesting.
You can let Codex pick the model automatically, or you can specify it yourself.
โ†’ ๐—ด๐—ฝ๐˜-๐Ÿฑ.๐Ÿฐ โ€” For your main agent and anything requiring deep reasoning. Complex logic, ambiguous tasks, security analysis.
โ†’ ๐—ด๐—ฝ๐˜-๐Ÿฑ.๐Ÿฏ-๐—ฐ๐—ผ๐—ฑ๐—ฒ๐˜…-๐˜€๐—ฝ๐—ฎ๐—ฟ๐—ธ โ€” Optimized for speed. Exploration, scanning, quick summaries. Use this for your worker agents.
Or actually any model you like and want!
You can also set reasoning effort per agent:
โ†’ high โ€” complex logic, edge case analysis โ†’ medium โ€” balanced default โ†’ low โ€” when speed matters more than depth

Practical example:
Your main agent runs gpt-5.4 with high reasoning. It spawns 3 spark agents with low reasoning to scan your codebase in parallel. They report back. Main agent synthesizes everything.
Codex also ships with 3 built-in agents out of the box:
โ†’ default โ€” general-purpose fallback
โ†’ worker โ€” execution-focused, for implementation tasks
โ†’ explorer โ€” read-heavy, for exploration and scanning
You can use these directly without any config. If you need something custom and deterministic, define your own agent in a TOML file:
name = "security-reviewer"
description = "Scans for security vulnerabilities"
developer_instructions = "Focus only on security risks. Report findings clearly."
model = "gpt-5.3-codex-spark"
model_reasoning_effort = "high"
Drop it in .codex/agents/ in your project (or ~/.codex/agents/ for personal use). Codex picks it up automatically.

๐—•๐—ฒ๐˜€๐˜ ๐˜‚๐˜€๐—ฒ ๐—ฐ๐—ฎ๐˜€๐—ฒ๐˜€
โ†’ Code review โ€” one agent per concern (security, performance, readability)
โ†’ Bug triage โ€” one agent per reported bug, all running at the same time
โ†’ Large codebase exploration โ€” split the repo, each agent scans a section
โ†’ Test coverage โ€” one writes tests, another checks edge cases, another validates
โ†’ Documentation โ€” agents scan different modules and generate docs in parallel
โ†’ Refactoring โ€” agents analyze different patterns across your codebase at once
The rule is simple: if the work can be split into independent chunks, subagents are the right tool.

๐—ช๐—ต๐—ฒ๐—ป ๐—ก๐—ข๐—ง ๐˜๐—ผ ๐˜‚๐˜€๐—ฒ ๐˜๐—ต๐—ฒ๐—บ
โ†’ Parallel writes to the same files โ€” you'll get conflicts
โ†’ Sequential tasks where step 2 depends on step 1 โ€” agents can't coordinate mid-run
โ†’ Simple single-file changes โ€” unnecessary overhead
Also worth knowing: subagents consume more tokens since each one does its own model and tool work independently. Use them when parallelism actually makes sense.

๐—ค๐˜‚๐—ถ๐—ฐ๐—ธ ๐˜€๐˜๐—ฎ๐—ฟ๐˜
Open Codex and try this:
"Review my project. Spawn 3 subagents:
Check for security vulnerabilities
Identify missing test coverage
Suggest performance improvements Wait for all three, then give me a prioritized action list."
That's it.

Subagents are one of those features that feel obvious once you see them. The main agent focuses on decisions. The subagents handle the noise.

Tech stack

  • Codex

Comments (6)

  1. Joshua ·

    Token usage might go up, but the time saved probably makes it 100% worth it

  2. Lateef ·

    The best part? No setup neededโ€ฆ just prompt it properly and it handles the orchestration\

  3. Idhika ·

    Using one agent for security, one for tests, one for performance is actually how real teams work ๐Ÿ‘€

  4. The devquee ·

    I like how you can mix models โ€” fast ones for scanning, smart ones for reasoning. Thatโ€™s clean architecture thinking

  5. Shreya ·

    The โ€œone brain, multiple workersโ€ idea makes so much sense โ€” surprised it took this long to ship tbh

  6. Nuel develops ·

    This is actually hugeโ€ฆ feels like Codex just became a full engineering team instead of a single assistant ๐Ÿคฏ

13 likes · 6 comments · 11 views

Explore more on Prompted