AI Agents
Advanced 13 min read AI Agents

Subagents

Delegation with focus

Subagents are specialized workers delegated a bounded sub-goal with their own loop, tools, and context — the coordinator decomposes work and merges results. Parallelism and focus come at a coordination cost.

subagentsdelegationparallelismcoordinationcontext isolation
Prerequisites: Planner Agents
Before we start

What you will learn

  • Justify when subagents beat one big loop
  • Bound sub-goals and context isolation
  • Merge and verify subagent outputs
Introduction

What is this?

Subagents are isolated loops with their own prompts, tools and history, delegated a bounded sub-goal by a coordinator. They win when tasks parallelize cleanly or need different tools/prompts than the main loop; they cost coordination, serialization overhead, and verification of their outputs.

Motivation

Why do you need it?

  • Isolation prevents cross-task context noise.
  • Parallel subagents shorten wall-clock time.
  • Specialized prompts/tools raise per-task quality.
  • Scoped delegation matches how real teams work.
Think about it

Mental model

Imagine

A lead engineer and specialists

Think of

Subagents

The lead (coordinator) splits the ship into deck + engine + navigation, each specialist (subagent) runs their own checklists with their own tools, then reports back. Parallel and focused — but the lead owns integration, acceptance, and the schedule.

Mechanics

How it works

  • Coordinator plans and identifies parallel/large sub-tasks.
  • Spawn subagents with a clear objective + scoped tools.
  • Share only what's needed (summary of context, not everything).
  • Merge results into the coordinator's plan.
  • Verify each subagent's deliverables before acceptance.

Fan-out, work, fan-in.

Plan
Delegate
Convert
Merge
Verify
Real world

In production

  • Research: one subagent per source/perspective, then synthesis.
  • Repo ops: parallel review subagents for files or services.
  • Multi-region ops: subagents run per-region runbooks concurrently.
Guidelines

Best practices

  • Give each subagent a crisp objective + exit criteria.
  • Scope tools and permissions per subagent.
  • Share summaries, not backstories; keep context lean.
  • Verify deliverables in the coordinator before integrating.
Watch out

Common mistakes

  • Subagents re-explore the same state the coordinator covered.
  • Fan-out without caps — cost multiplies with agents.
  • Blindly trusting subagent outputs as ground truth.
Root cause analysis

Common issues

Error
Subagents block on shared resources
Root cause

Contended tools

Fix

Serialize writes or partition work by resource scope.

Error
Cost explodes with subagents
Root cause

Unbounded fan-out

Fix

Cap parallel spawns; reuse results; merge related sub-tasks.

When things break

Debugging tips

  • Slow convergence → overlapping sub-tasks; partition cleanly by ownership.
  • Duplicate work → share a task log so workers don't collide.
  • Inconsistent merges → define deliverable format per subagent.
Interviews

Interview checkpoint

Test yourself

Quick quiz

0/2
1

A reason to use subagents:

2

Subagent outputs can be trusted without verification.

Go deeper

Official documentation