Building with AI

Sub-agents

3 min readintermediateUpdated 28 Sept 2026
1 · In one line

A sub-agent is a helper AI that a main agent sends off to do one side task in its own workspace, then report back a short result.

1 · What it is

An AI agent is a model that can use tools and take steps on its own. It can also hand tasks to sub-agents. A sub-agent is a separate AI helper. It has its own instructions and tools, and it handles one kind of task. The main agent gives it a job. The helper works on it alone, then reports back what it found.

The point is to keep the main agent’s working memory clean. That memory is the context window: the text a model can see at once. Picture asking a coding assistant which tests fail. A helper runs the whole test suite, reads every line of output, and sends back just the failing tests. The long output never lands in your main conversation.

Helpers can also work side by side. In a research system, a lead agent plans the search and starts several sub-agents to explore different parts at once. In that system, running three to five helpers at once, each using several tools at once, cut the research time for hard questions by up to 90%. It could also go wrong: early versions sometimes started 50 sub-agents for a simple question.

For builders: a manager agent can keep control and call specialist agents as tools. Helpers can also be lined up in a chain, where each one passes its result to the next. By default a helper does not remember past jobs. Only the main agent keeps the memory of your conversation.

2 · Why it exists

One agent doing everything in one conversation runs into trouble.

Cluttered memorySearch results, logs and file contents can flood the conversation, even when they are never needed again.
One thing at a timeSearching sources one after another can be very slow.
Too many jobsWithout helpers, one set of instructions has to handle everything.
3 · How it works

Follow one big research task through a main agent and its helpers.

The helpers do the messy reading. Only their short summaries reach the main conversation.
  1. 1 · splitThe main agent looks at the task and decides which parts to hand out.
  2. 2 · delegateEach sub-agent gets a short description of its part of the task.
  3. 3 · workEach one works in a separate context window, sometimes at the same time as the others.
  4. 4 · reportIt returns only its result, and the main agent combines the results.

Sub-agents keep the main conversation short by doing side work somewhere else.

4 · Where it's used
WhoWhat they askWhat it works with
Software developer“Which of our tests are failing and why?”A helper runs the whole test suite and reports only the failures
Research assistant“What are the main sides of this big question?”A lead agent starts several helpers to explore different parts at once
Code review team“Are there performance problems in this change?”A reviewer helper finds issues, then a second helper fixes them
Developer on call“What do these long logs say went wrong?”A helper reads the logs and returns only a short summary
5 · What it solves, and what it doesn't
solves
  • Bulky output stays inside the helper, so the main conversation stays clear.
  • Independent parts of a task can run in parallel.
  • Each helper can have its own focused instructions and a limited set of tools.
  • Simple side tasks can go to a faster, cheaper model.
doesn't solve
  • They use many more tokens, so they cost more than a single chat.
  • They fit poorly when every step needs the same shared context.
  • Vague instructions can make helpers repeat each other's work.
  • They add waiting time, so a quick change is often faster without them.
6 · Go deeper

Sources used

This explainer is written in original language. The links below support its factual claims.

  1. docsCreate custom subagents, Anthropic (Claude Code Docs) · read 28 Sept 2026
  2. officialHow we built our multi-agent research system, Anthropic · read 28 Sept 2026
  3. docsAgent orchestration, OpenAI Agents SDK · read 28 Sept 2026
  4. docsSubagents, LangChain · read 28 Sept 2026
  5. officialBuilding effective agents, Anthropic · read 28 Sept 2026