Core Concepts

Subagent

A subagent is a secondary AI agent that a main agent spawns to handle a specific sub-task, usually with its own focused instructions and tools, and reports back to the agent that spawned it.

Subagent ASubagent BMain agent
A main agent delegates to subagents, which execute and report back.

When a task has a piece of work that needs its own focus — a big chunk of context to search through, a specialized set of tools, or a risk of cluttering the main conversation — a main agent can delegate that piece to a subagent instead of doing it inline. The subagent gets a specific instruction, does its work (often in its own isolated context), and returns a result to the main agent, which continues the overall task.

The appeal is mostly about context management: pulling a large, noisy sub-task (like reading through many files, or exploring an unfamiliar API) into a subagent's own context keeps that noise out of the main agent's context, so the main agent's reasoning stays focused on the overall goal rather than the details of how one piece got done.

Subagents are usually configured with a narrower toolset or a specific system prompt tuned for their sub-task, and they're typically short-lived — spawned for one job and discarded once it reports back, rather than persisting as an ongoing collaborator.

How it works

The diagram shows a main agent dispatching work to subagents A and B — one-directional, since the arrangement here is a strict hierarchy: the main agent delegates and the subagents execute and report back, rather than subagents dispatching work of their own. In Claude Code specifically, subagents are one level deep only — a subagent it spawns cannot itself spawn further subagents — which keeps the delegation tree simple to reason about, though other agent frameworks may allow deeper nesting.

Example

A coding agent asked to 'update the API docs to match the current code' might spawn a subagent whose only job is to read through the source files and summarize every public function's current signature, then hand that summary back — keeping the main agent's context focused on writing the docs rather than full of raw file contents.

How it differs

A subagent is a specific pattern within the broader idea of a multi-agent-system: multi-agent system is the general category (any architecture with multiple cooperating agents), while subagent specifically describes a temporary, hierarchical delegate spawned by one main agent for one sub-task.

Common misconceptions

Often assumed: Subagents can keep spawning their own subagents indefinitely.
Actually: In Claude Code specifically, subagents are one level deep only — a subagent cannot itself spawn further subagents — though this limit is implementation-specific and other frameworks may differ.
Often assumed: A subagent is just a separate conversation with the same context as the main agent.
Actually: Subagents typically run in their own isolated context with a narrower toolset and instructions, precisely so their work doesn't clutter the main agent's context.

FAQ

What is a subagent in AI coding tools?
It's a secondary agent that a main agent spawns to handle one specific sub-task, often with its own tools and isolated context, which then reports its result back.
Can a subagent spawn its own subagents?
In Claude Code, no — subagents are one level deep only, so a subagent cannot itself spawn further subagents; other frameworks may differ.
Why use a subagent instead of just doing the sub-task inline?
Mainly to keep the main agent's context focused — a subagent can absorb a noisy sub-task like reading many files and return just the summary.

Last checked: 2026-08-28

Related terms