ع
Learn Tracks Reference Guides Saved
Concepts, explained

Recursive agents: how a coding agent gets reliable by calling itself

A capable model rarely fails a big job because it isn't smart enough. It fails because the work wasn't specified, split up, or checked. Recursive agents fix the management, not the intelligence.

12 min read · Updated 2026-07-12
Recursive agents: how a coding agent gets reliable by calling itself

Hand a genuinely capable model a big, messy job and watch what happens. It starts strong, does real work, and then — somewhere past the halfway mark — it declares victory with half the checklist unfinished. Or it “reviews” its own output and passes it. Or it quietly forgets the one constraint you were most worried about. The intelligence was never in question. The management was.

There’s a useful way to name this: today’s coding agents are mismanaged geniuses. The model already knows more than any single person on your team. What it lacks is a manager — something to specify the work precisely, split it into pieces the right size, hand each piece to a fresh mind, and check the results before calling anything done. Recursive agents are the most concrete answer we have to that management problem. This guide is about the principles behind them, in plain language, and why they’re really a story about trust.

Mismanaged genius: the gap isn’t intelligence

For a couple of years the assumption was that better AI meant a smarter model, and a smarter model would mean more reliable work. Capability climbed fast — and the reliability gap stubbornly didn’t close at the same rate. A model can ace a hard reasoning test and still botch a long, multi-part task, not because it got dumber, but because a long task punishes different weaknesses: staying on-goal for an hour, resisting the urge to grade its own homework, keeping fifty small requirements all in view at once.

Those aren’t intelligence failures. They’re the failures of a brilliant employee with no manager. And that reframe matters, because it changes what you reach for. If the problem were intelligence, you’d wait for a bigger model. If the problem is management, you can fix it now — by putting a better structure around the model you already have.

Here’s the part that surprises people: with the right structure, a modest model can outrun a much larger one on this kind of work. A big model asked to do everything in one pass carries the whole job in one crowded mind. A smaller model, given a manager that splits the work into small checked pieces, doesn’t have to. The orchestration compounds. This is the clearest evidence that the bottleneck was never raw brainpower — it was the missing layer of specification, coordination, and verification. Trust is just another word for reliability, and reliability is a management outcome.

What “recursive” actually means

Start with an ordinary agent. As we cover in what is an AI agent, it works in a loop — it acts, observes the real result, and decides the next step, over and over, until the job is done. One mind, one context, grinding through the task.

A recursive agent adds one move: it can call itself. Faced with a job too big to hold in one head, it doesn’t try to swallow the whole thing — it spins up copies of itself as sub-agents, hands each one a small, well-defined slice with its own fresh context, and coordinates their results. And because each sub-agent is itself a full agent, it can do the same thing: split its slice further, spawn its own sub-agents, go a level deeper. The recursion runs as deep as the problem demands.

The human analogy is a good manager who delegates. You don’t personally investigate every thread of a big project — you hand a piece to someone capable, who may hand part of their piece to someone else, and so on, with each person focused on one thing and reporting up. Nobody holds the entire problem in their head at once, and that’s exactly why it gets done well. A recursive agent is that org chart, assembled on demand for a single task.

The rest of this guide is the manager’s playbook: the handful of principles that decide whether all that delegation produces something you can trust — or just a bigger, faster mess.

Principle 1 — Explore the context, don’t swallow it

The instinct with a powerful model is to feed it everything — the whole codebase, every document, all the history — and let it sort things out. That instinct backfires. As we explain in context engineering, a model’s working memory is large but finite, and a cluttered window produces worse answers than a focused one. Cram everything in and the signal the model needs drowns in noise it doesn’t.

Recursive agents flip the relationship. Instead of the context being poured into the agent, the context sits outside it — as files, folders, a workspace the agent can move around in — and the agent treats it as something to explore, pulling in only the slice it needs at the moment it needs it. It reads one file, learns something, decides what to look at next. When a piece of the job needs deep attention, that piece gets its own sub-agent with its own clean window, so no single mind ever has to hold the whole thing.

The practical payoff is that “too big to fit” stops being a wall. A job that would overflow any single context window — a sprawling repository, a folder of hundreds of documents — becomes tractable, because it’s never all in one place at once. The agent works on the material the way you’d work on a filing cabinet: not by memorizing every folder, but by knowing how to find the right one.

Principle 2 — Let the agent split the work

Here’s the line that separates a genuinely recursive agent from a clever-looking imitation. You can build a fixed pipeline by hand — “split the input into ten chunks, run an agent on each, merge the results.” That’s useful, but it isn’t recursive in the sense that matters: you decided the shape in advance, and it splits every job the same way whether or not that fits. Hand it a task that’s really three uneven problems wearing a trench coat, and it still cuts ten equal slices.

A recursive agent decides its own breakdown. It looks at the actual task and works out how many pieces there are, which ones are big enough to delegate, how deep to recurse on each, and when to stop. The decomposition is a decision the model makes about this job, not a template you imposed on every job. That’s what lets it stay reliable as tasks get lumpy and unpredictable — the parts of real work that a fixed script handles worst.

This is subtle but load-bearing, so it’s worth stating plainly: a hardcoded map-reduce is not a recursive agent. Both spawn sub-agents; only one adapts. When you’re evaluating a tool or writing a prompt, that’s the tell to look for — does the agent choose how to divide the problem, or was the division baked in before it ever saw the work?

Principle 3 — The reviewer is never the author

Ask a model to check its own output against a rubric and it leans toward approving it. This isn’t laziness; it’s the same pull a person feels proofreading their own writing — you read what you meant, not what’s there. A reviewer who also wrote the thing is a soft reviewer, and soft review is where unreliable results slip through wearing a stamp of approval.

The recursive fix is structural: the agent that verifies a piece of work is a different agent from the one that produced it, with its own fresh context and one job — to find what’s wrong. Push it further and the check becomes adversarial: spin up a sub-agent whose explicit brief is to attack the result, to refute it against the rubric rather than bless it. Several independent skeptics beat one agreeable check. (This is one of the core patterns in dynamic workflows, where an agent writes a script that pairs every finding with a separate verifier.)

The reason this matters so much for trust is that the two most common failure modes of a long job — stopping early and grading its own homework — are both failures of self-assessment. An agent that can’t tell it’s only 60% done, or can’t see the flaw in its own answer, is fixed not by making it smarter but by making the check someone else’s job. Separation of duties is an old idea in every serious organization. Recursive agents borrow it.

Principle 4 — Equip each sub-agent on purpose

A sub-agent is only as good as what it’s given. Send one off to do a job without the specific tool it needs, or without the context that defines “good” for this task, and it will improvise — confidently, and often wrongly. Most unreliable sub-agent work traces back not to a bad model but to a badly equipped one: it never had what the job required.

So the reliable pattern is to declare, up front, exactly what each sub-agent gets before it starts: the tools it’s allowed to use, the skills or reference material it needs, and the slice of context that tells it what success looks like. This does two things at once. It makes the sub-agent capable — it has the right hands for the work — and it makes the whole system legible, because you (and the parent agent) can see what each piece was equipped with and therefore what it could and couldn’t have done. A job that fails because a sub-agent lacked a tool is a diagnosable failure. A job that fails because forty things were vaguely available and it picked wrong is not.

This is the quiet engine of reliability in the whole approach. It’s less glamorous than an agent spawning a swarm of copies of itself, but “every sub-agent was given precisely what its task required, and nothing it didn’t” is what separates a recursive agent you can trust from an impressive demo that works once and never again.

Principle 5 — Keep the runs that worked

The first time an agent solves a hard, novel problem well, something valuable just happened that’s easy to throw away: a sequence — the way it broke the job down, the order it worked in, the checks it ran, the tools each step used. Run the same job cold tomorrow and you’re rolling the dice again on whether it finds that same good path.

The move is to capture the good run and turn it into a reusable recipe. Take a session that went well and encode its shape — the decomposition, the verification steps, the equipment each stage needed — into a workflow you can point at similar jobs later. You’re not saving the answer; you’re saving the method. Done right, a one-time success becomes a repeatable one, which is the entire game when your goal is reliability rather than a lucky demo.

There’s a limit worth naming: a captured recipe is reliable for jobs that resemble the one it came from, and less so the further you drift from it. It’s a template to adapt, not a spell to recite — the recursive agent should treat a saved workflow as a starting shape it can adjust, not a script to run blindly. Used that way, capturing good runs is how a team compounds: every hard problem solved well becomes a tool for the next person who hits something like it.

When recursion is the wrong tool

All of this is powerful, which makes it tempting to overuse — and that’s the mistake to guard against. Recursion has real costs: every sub-agent spends tokens, every extra level of depth adds latency, and an agent that decomposes too eagerly can run up a bill doing with a fleet what one agent would have done in a single pass.

So the honest question before reaching for a recursive agent is: does this job actually exceed one mind in one context? Most work doesn’t. A quick edit, a normal question, a single review — one agent handles those fine, and wrapping them in recursion just burns compute for no gain. Save the machinery for the jobs that are genuinely large, genuinely parallel, or adversarial in a way a single context can’t hold: a repo-wide migration, an audit across hundreds of files, a deep investigation with competing theories.

When you do reach for it, bound it deliberately. A depth limit caps how many levels deep the recursion can go. A token budget caps what it can spend. A clear stop condition — no new findings, no errors left, the goal provably met — ends it when the work is done instead of leaving it to decide for itself. These guardrails are blunt, but they’re what keep a powerful tool from becoming an unpredictable one. Power without a budget isn’t reliability; it’s just risk with better production values.

The bigger picture: reliability is trust

Step back and the whole approach is one idea repeated at every level: don’t make the model smarter — give it a manager. Specify the work, split it into pieces the right size, hand each to a fresh mind that’s properly equipped, check the results with someone other than the author, and keep the methods that work. None of those moves is exotic. They’re what good organizations have always done with talented people, ported onto talented models.

That’s why this matters beyond the mechanics. The reason “agent” hasn’t yet become “teammate” for most serious work is trust, and trust is nothing more than reliability you’ve earned over time. A model you can’t predict is a model you have to double-check, which cancels most of the leverage. The principles here — explore context instead of swallowing it, let the agent split its own work, separate the doer from the checker, equip every piece on purpose, keep the runs that worked, and bound the whole thing — are how you convert raw capability into results you can actually rely on.

The intelligence is already here. The interesting work now is management. If you take one thing from this: a recursive agent is a lot of power pointed at one problem, and power like that deserves guardrails. Recurse responsibly.

Topics

Questions people ask

Do I need to be a programmer to use recursive agents?
No. You describe the job in plain language and the agent writes and runs its own orchestration — spawning the sub-agents, checking their work, and reporting back. Understanding the principles just helps you ask for the right shape and spot when a result hasn't actually been verified. You read and approve; you don't author the machinery.
How is a recursive agent different from just running many agents in a fixed pipeline?
A fixed pipeline is written ahead of time and has to guess the shape of every job — it always splits the work the same way. A recursive agent decides its own breakdown for the task in front of it: how many pieces, how deep to go, when to stop. That self-decomposition is the whole difference. A rigid script can't adapt when the job turns out bigger or messier than expected; a recursive agent can.
Doesn't an agent calling itself over and over get expensive or run away?
It can, which is why recursion is a tool you point at hard jobs, not a default. In practice you bound it: a depth limit on how many levels deep it can go, a token budget it can't exceed, and a clear stop condition so it ends when the work is done rather than looping forever. Most everyday tasks need none of this — one agent in one context is cheaper and just as good.
Can a smaller, cheaper model really be reliable this way?
Often, yes — for structured, long-running work. When a job is broken into small, well-specified pieces that each get checked, a modest model with a good harness around it can outperform a much larger model asked to do the whole thing in one pass. The orchestration compounds. It won't make a weak model brilliant, but it narrows the gap far more than raw size does on this class of task.
Put it into practice
Take the guided course
Start