How to run subagents in Codex
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
13 likes · 6 comments · 11 views
Comments (6)
Token usage might go up, but the time saved probably makes it 100% worth it
The best part? No setup neededโฆ just prompt it properly and it handles the orchestration\
Using one agent for security, one for tests, one for performance is actually how real teams work ๐
I like how you can mix models โ fast ones for scanning, smart ones for reasoning. Thatโs clean architecture thinking
The โone brain, multiple workersโ idea makes so much sense โ surprised it took this long to ship tbh
This is actually hugeโฆ feels like Codex just became a full engineering team instead of a single assistant ๐คฏ