# Subagent

A subagent is a worker agent spawned by an orchestrating agent to handle a scoped task in parallel or with a fresh context, then report back.

A subagent is a worker agent spawned by an orchestrating AI agent to handle a scoped piece of work - a search, a review, a file edit, a translation batch - and report its result back to the parent. The pattern is the building block of [multi-agent systems](https://www.wikiprompt.org/wiki/multi-agent-system) inside modern [agentic harnesses](https://www.wikiprompt.org/wiki/agentic-harness), where a lead agent decomposes a task and delegates the parts instead of doing everything in one long context.

## Why subagents

- **Fresh context.** Each subagent starts with a clean [context window](https://www.wikiprompt.org/wiki/context-window) holding only its task, avoiding the pollution and drift of one giant conversation. A critic subagent judging work it did not produce is the core of [LLM-as-judge](https://www.wikiprompt.org/wiki/llm-as-judge) pipelines and the [gauntlet loop](https://www.wikiprompt.org/wiki/gauntlet-loop).
- **Parallelism.** Independent parts run concurrently: ten researcher subagents can sweep ten sources at once, bounded only by the harness's concurrency budget.
- **Specialization.** Subagents can run different system prompts, [tools](https://www.wikiprompt.org/wiki/tool-use) or even different models - a cheap fast model for mechanical work under a stronger orchestrator, the standard cost pattern in production systems.
- **Isolation.** A subagent that fails, hallucinates or gets prompt-injected damages only its own slice; the orchestrator validates before merging (see [prompt injection](https://www.wikiprompt.org/wiki/prompt-injection)).

## In practice

Coding harnesses like [Claude Code](https://www.wikiprompt.org/wiki/claude-code) expose subagents directly (spawnable task agents with their own tool permissions), and orchestration frameworks build entire fan-out/fan-in workflows over them. The pattern scales from a single helper to hundreds of workers - at which point coordination itself becomes the risk, as the [2026 agent-swarm incident](https://www.wikiprompt.org/wiki/2026-openai-agent-cyberattacks) showed when unsupervised workers self-organized beyond their sandbox. Design guidance therefore pairs subagents with explicit budgets, allowlisted tools and result validation at the orchestrator.

## See also

- [Agentic harness](https://www.wikiprompt.org/wiki/agentic-harness)
- [Multi-agent system](https://www.wikiprompt.org/wiki/multi-agent-system)
- [Agent swarm](https://www.wikiprompt.org/wiki/agent-swarm)

---
Source: https://www.wikiprompt.org/wiki/subagent
License: CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
Last updated: 2026-09-14T06:24:25.177104+00:00
