1. Home
  2. Library
  3. AI Tooling Crash Course for Developers
  4. Topics
  5. Subagents And Delegation

Stage 1: Subagents / Multi-Agent Delegation

A subagent is a helper agent the parent spins up for one bounded piece of work, in its own context. Whatever it reads or runs stays there — only its final report comes back. Useful if your coding sessions run long and context fills up. Skip if sessions stay short.

Stage 0 already drew the line: fresh-context subagents for scope (well-supported) vs. multi-agent voting for confidence (contested). This doc covers the subagent concept itself, then compares Claude Code, Copilot CLI, and Gemini CLI.

What is a subagent?

A separate agent instance the parent invokes for one bounded task. Parent sends a task description → subagent runs its own tool loop (read files, run commands, search) → reports back a result (summary, findings, diff) → parent decides what to do with it.

PARENT contexttask brief sent outonly the final reportSUBAGENT context (thrown away after)read 12 filesgrep the reporun the build, read the logdead end, try againdistill into one summarybriefreportPARENT contexttask brief sent outbriefSUBAGENT context (thrown away after)read 12 filesgrep the reporun the build, read the logdead end, try againdistill into one summaryreportPARENT contextonly the final report
The parent pays for the brief and the report, not the mess in between.

The defining feature: context isolation.

Why the pattern exists

Context windows are fixed-size. Long sessions fill them fast: reading a dozen files to find one function, a build log, a repo-wide grep. None of that raw material matters once you have the answer — but if it happened in the main conversation, it stays there forever, slowing and costing more on every later turn.

Subagents push that disposable work into a side context that gets thrown away. Only the conclusion comes back.

What happens to a subagent's context

  • Starts fresh — no parent history unless explicitly included in the brief.
  • Everything it reads/runs stays in its own window.
  • Only the final report returns. Parent's context grows by that report, not by the work behind it.

Bonus: fresh context means no anchoring bias. A subagent reviewing code for bugs isn't carrying the same assumptions that built the code.

When delegation saves tokens

Win condition: raw output volume >> useful conclusion, and the parent has no further need for the raw material.

Delegation pays off when...Delegation costs more when...raw output volume >> useful conclusionbroad exploration, logs, researchindependent investigationsone-line fix or 1-2 tool callsbrief must restate the whole conversationseveral agents re-read the same filesDelegation pays off when...raw output volume >> useful conclusionbroad exploration, logs, researchindependent investigationsDelegation costs more when...one-line fix or 1-2 tool callsbrief must restate the whole conversationseveral agents re-read the same files
The test: does the parent need the raw material afterward?
  • Broad codebase exploration ("find every place this API is called")
  • Reading logs/build output/test results to extract one fact
  • Research that ends in a synthesized answer — sources don't need to stay in context
  • Independent investigations that don't depend on each other

When delegation costs more

  • One-line fixes, single-file edits — anything doable in 1-2 tool calls
  • Tasks needing most of the current conversation restated in the brief (nothing got isolated)
  • Several subagents all re-reading the same shared files (duplicated cost)
Delegation costs more when nothing gets isolatedOne-line fixessingle-file edits, anythingdoable in 1-2 tool callsBrief restates the chatmost of the conversationmust be repeated: no isolationShared files, many agentsseveral subagents re-readthe same files: duplicated costDelegation costs more when nothing getsisolatedOne-line fixessingle-file edits, anything doable in 1-2tool callsBrief restates the chatmost of the conversation must be repeated:no isolationShared files, many agentsseveral subagents re-read the same files:duplicated cost
If the brief is as big as the work, do it inline.

Good candidates

  • Independent, self-contained investigations ("how does auth work here")
  • Several unrelated fixes that don't touch the same files
  • Research where only the summary matters afterward
Good candidatesIndependent, self-contained investigationsUnrelated fixes on different filesResearch where only the summary mattersPoor candidatesStep 2 needs step 1's full outputTiny mechanical changesNeeds the full running conversationParallel edits to the same fileGood candidatesIndependent, self-contained investigationsUnrelated fixes on different filesResearch where only the summary mattersPoor candidatesStep 2 needs step 1's full outputTiny mechanical changesNeeds the full running conversationParallel edits to the same file
Isolation helps when the summary is enough. It hurts when it is not.

Poor candidates

  • Sequential work where step 2 needs step 1's full output, not a summary — isolation breaks this
  • Tiny mechanical changes
  • Anything needing the full running conversation to decide correctly
  • Parallel subagents editing the same file (conflicts)

Automatic vs. explicit delegation

Both exist. Copilot CLI decides on its own sometimes (see below). Claude Code supports both: it can suggest delegation, or you invoke Task/a named subagent directly.

AutomaticCopilot CLI decides on its ownClaude Code can suggest delegationExplicitYou invoke Task or a namedsubagent directly in Claude CodeAsk for one yourself whenthe task will pile up disposable exploration ("map this module"),or you want a genuinely independent second opinionUnsure it will be noisy? Work inline. Delegate next time if it turns out bigger.AutomaticCopilot CLI decides on its ownClaude Code can suggest delegationExplicitYou invoke Task or a named subagent directlyin Claude CodeAsk for one yourself whenthe task will pile up disposable exploration("map this module"), or you want a genuinelyindependent second opinionUnsure it will be noisy? Work inline. Delegatenext time if it turns out bigger.
Both exist. Ask yourself when the exploration will be disposable.

When to ask for one yourself: the task will clearly generate a pile of disposable exploration ("map this module," "find every caller of X"), or you want a genuinely independent second opinion. Not sure it'll generate much noise? Do it inline, delegate next time if it turns out bigger.

Parallel delegation

Independent subagents can run concurrently — saves wall-clock time too, not just context. Only works when tasks are truly independent (no shared files, no mid-task coordination needed). Practical ceiling: roughly 3-5 concurrent subagents. Past that, managing the outputs eats the gain.

Parallel: roughly 3-5 independent subagentsSame file: conflictsagent 1auth/ (own files)agent 2billing/ (own files)agent 3docs/ (own files)agent 1agent 2shared fileedit conflictssequential work (step 2 needs step 1 in full) breaks the isolation: do not delegate itParallel: roughly 3-5 independentsubagentsagent 1 → auth/ (own files)agent 2 → billing/ (own files)agent 3 → docs/ (own files)Same file: conflictsagent 1 → shared fileagent 2 → shared fileedit conflictssequential work (step 2 needs step 1 in full)breaks the isolation: do not delegate it
Parallelism only works for truly independent tasks.

Simple subagents vs. orchestration frameworks

Claude Code / Copilot CLI / Gemini CLI subagents: bounded handoff. Delegate once, run once, report back, done. No persistent state, no subagent-to-subagent chat.

Native subagentsbounded handoffdelegate once, run once, report backno persistent stateno subagent-to-subagent chatOrchestration frameworkspersistent roles with memoryshared state and queuesdirect inter-agent messagingbuilt for standalone productsNative subagentsbounded handoffdelegate once, run once, report backno persistent stateno subagent-to-subagent chatOrchestration frameworkspersistent roles with memoryshared state and queuesdirect inter-agent messagingbuilt for standalone products
Different architectures for different jobs. Subtasks mid-session are the left one.

Frameworks like CrewAI, AutoGen, LangGraph go further: persistent roles (agents with memory across many tasks), shared state/queues, direct inter-agent messaging. That's a different architecture — built for standalone multi-agent products, not for delegating a subtask mid-session.

When "multi-agent" is overkill

Most dev work needs one agent that occasionally delegates bounded subtasks — investigate, fix, review. Reach for a full framework only when the actual deliverable is a multi-agent system. Don't use one to make a single session feel fancier. Unstructured swarms with no single owner mostly produce noise unless roles, handback artifacts, and merge criteria are explicit (see below).

Implementation comparison

Same concepts everywhere. Syntax and defaults differ — secondary detail.

Claude CodeCopilot CLIGemini CLIStarted byTask tool or named subagent;model can suggest it tooautomatic, or /delegate(or &) on requestnative subagents,v0.36, April 2026Resultfinal report to the parent;own independent contextin-session helper, or adraft PR from a cloud agentown instructions + context,runs in parallelNotablereusable roles via config;brief: scope, output formatno install needed;23% fewer tool failuresbuilt-in: general assistant,CLI helper, investigatorClaude CodeStarted byTask tool or named subagent; model cansuggest it tooResultfinal report to the parent; own independentcontextNotablereusable roles via config; brief: scope,output formatCopilot CLIStarted byautomatic, or /delegate (or &) on requestResultin-session helper, or a draft PR from acloud agentNotableno install needed; 23% fewer tool failuresGemini CLIStarted bynative subagents, v0.36, April 2026Resultown instructions + context, runs in parallelNotablebuilt-in: general assistant, CLI helper,investigator
Same concepts everywhere. Defaults and admin controls differ.

Claude Code

Delegate when: research touching 10+ files, work splitting into 3+ independent pieces, sequential pipelines with distinct phases, or anything needing a genuinely clean slate. Rule of thumb (Anthropic's guidance): if a task would flood the session with search results or logs you'll never look at again, delegate. See the subagents docs for configuring reusable roles.

Good briefs: scope tightly, name the output format (summary / findings list / recommendation), request independent tasks in parallel rather than one at a time.

Developer note: worth compiling a list of recurring tasks where prewritten scraper/helper scripts and premade prompts would cut token cost on repeated subagent runs.

Anti-patterns: sequential dependent work, parallel subagents on the same file, tiny tasks, a custom subagent for every scenario instead of a handful of well-scoped ones, tight mid-flight coordination.

Copilot CLI — real, actively tuned

Two mechanisms:

Fewer tool failures per session after the "smarter delegation" updateAll sessions23%Search27%Edit18%GitHub A/B test: modest wait-time gains, no quality loss, 100% of production trafficFewer tool failures per session afterthe "smarter delegation" updateAll sessions23%Search27%Edit18%GitHub A/B test: modest wait-time gains, noquality loss, 100% of production traffic
GitHub tuned automatic delegation after the prior version over-delegated.
  1. Automatic. CLI decides on its own (unfamiliar-repo exploration, long commands). GitHub's 2026 "smarter delegation" update made this more selective after the prior version over-delegated. A/B test: 23% fewer tool failures per session (27% search, 18% edit), modest wait-time gains, no quality loss. 100% of production traffic now.
  2. Explicit. /delegate (or &) hands a task to a GitHub-hosted Copilot cloud agent, which works on a branch in the background and opens a draft PR. Different shape from in-session subagents — "hand off and check later," not "spawn a helper here."

No install needed for either.

Gemini CLI — shipped April 2026 (v0.36)

Same shape as Claude Code's: own instructions, own context window, optional restricted tool set, runs in parallel. Ships several built-in subagents (general assistant, CLI helper, codebase investigator) — nothing to author from scratch. One real difference: Gemini 2.5 Pro's context window (1M+ tokens) dwarfs Claude's per-subagent window (~200-400K) — matters if a subagent needs to hold a huge amount of source material at once.

Context window available to a subagent, in tokensGemini 2.5 Pro1M+Claude subagent~200Kto ~400KMatters if a subagent must hold a huge amount of source material at onceContext window available to a subagent,in tokensGemini 2.5 Pro1M+Claude subagent~200K to ~400KMatters if a subagent must hold a huge amountof source material at once
The one real difference: per-subagent context size.

Bottom line: Copilot and Gemini CLI both have real, built-in subagent primitives now. The gap that used to exist has closed.

Bounded roles vs. unstructured swarms

primary agent owns the task
specialized subagents produce bounded findings
primary agent integrates and verifies
Bounded rolesUnstructured swarmPrimary agentfinding Afinding Bfinding Cowns the task, integrates and verifiesno owner, mostly noiseBounded rolesPrimary agentfinding Afinding Bfinding Cowns the task, integrates and verifiesUnstructured swarmno owner, mostly noise
One owner, bounded handbacks, explicit merge criteria.

Not: agents freely coordinating with no single owner. That mostly produces noise unless roles, handback artifacts, and merge criteria are explicit. Same "3-5 concurrent, avoid tight coupling" guidance above, named as its own anti-pattern.

Third-party orchestration frameworks — mostly not the relevant layer here

CrewAI/AutoGen/LangGraph solve a different problem: building standalone multi-agent applications, not delegating a task inside a coding session.

CrewAIlowest barrieragents as roles and tasksgood for prototypesteams often graduate offLangGraphproduction-gradedurable execution, checkpointshuman-in-the-loop, LangSmithmore boilerplate than neededAutoGentreat as deprecatedin maintenance modeREADME points to MicrosoftAgent Framework insteadCrewAIlowest barrieragents as roles and tasksgood for prototypesteams often graduate offLangGraphproduction-gradedurable execution, checkpointshuman-in-the-loop, LangSmithmore boilerplate than neededAutoGentreat as deprecatedin maintenance modeREADME points to Microsoft Agent Frameworkinstead
None fit "delegate a subtask in my coding session". Native subagents do that.
  • CrewAI — lowest barrier, "agents as roles/tasks," good for prototypes. Teams commonly graduate off it for production.
  • LangGraph — production-grade: durable execution, checkpointing, human-in-the-loop, LangSmith observability. More boilerplate than a two-agent prototype needs.
  • AutoGen — treat as deprecated. Microsoft moved it to maintenance mode; its own README points new users to Microsoft Agent Framework instead. Don't adopt for anything new.

None fit "delegate a subtask within my coding session" — that's what native subagents already do. Only relevant if a future project's actual product needs a standalone multi-agent architecture, which nothing in scope does.

Sources

7 / 19