Patterns and Multi-Agent Systems
This content was developed with AI assistance and is regularly reviewed for accuracy.
Snapshot: October 2026. Model names, prices, and product features change monthly; What's New in AI is the maintained chronology.
Every agent you will build or buy is some arrangement of the same few parts: a loop that observes, decides, and acts; a planner that breaks the goal down; an evaluator that checks the work; and, when one agent is not enough, a way to split work across several. In 2026 these patterns stopped being framework abstractions and became first-party features. Claude Code ships subagents, agent teams, and dynamic workflows; Anthropic's engineering blog gave the scaffolding a name, the harness, and a vocabulary. This page teaches the patterns once, with one set of diagrams, and maps each to the primitive you would actually use.
Learning focus
- Describe the agent loop and the harness around it
- Choose between planning, reflection, and verification patterns for a single agent
- Recognize the four multi-agent shapes and the first-party primitive that implements each
- Avoid the anti-patterns that waste tokens or never terminate
The agent loop and the harness
The base pattern is the loop. The agent reads the brief, plans a step, acts (usually by calling a tool), observes the result, and decides whether the goal is met. If not, it plans again. An evaluator, whether a test suite, a grader model, or a human, closes the loop.
Everything around the model that makes this loop reliable is the harness: in Anthropic's March 2026 definition, "the scaffolding of prompts, agents, tools, and orchestration around a model." The harness decides what the model sees, which tools it can call, when its context is reset, and what counts as done. A striking result from that post: the same model given a plain prompt produced non-working output in twenty minutes, while the same model inside a full harness produced a working application in six hours at a far higher cost. The harness, not the prompt, made the difference. Anthropic's caution applies too: every harness component encodes an assumption about what the model cannot do, so re-examine the harness with each new model.
Older pattern names still appear in docs. ReAct (reason, then act, then observe) is simply this loop with the reasoning written out, and current models reason natively, so you do not need to prompt for it. Chain-of-thought prompting ("think step by step") is obsolete for the same reason; depth is now an effort setting, not a phrase.
Single-agent patterns
Planning
The agent produces a plan before acting, and you can review the plan before any change happens. Claude Code's Plan Mode is this pattern as a product feature: read-only exploration, a written plan, then execution in a separate mode. Use planning when the task is long, when you want an estimate, or when you want approval before execution. Avoid it for five-minute tasks, where planning costs more than doing.
Reflection and the evaluator
The agent, or a second agent, critiques the output and the first agent revises. Anthropic's harness work splits this into three roles: a planner that decides what to do, a generator that does it, and an evaluator that judges the result against criteria. The split matters because a model grading its own work in the same context tends to agree with itself; a separate evaluator with fresh context and explicit criteria does not. Use it for quality-critical outputs, creative work, and anything where you can state what good looks like.
Verification
The agent checks its own work with something deterministic before returning: tests pass, the JSON validates, the figure matches the source, the file exists. This is the cheapest reliability pattern and the one most often skipped. The lesson from Anthropic's February 2026 compiler project applies everywhere: passing tests does not guarantee correct software, but no tests guarantees you will not find out. Evals for Agents turns this into a method.
Memory and handoff
Agents keep three kinds of state. Working context is the conversation and recent tool results. Project memory is what persists across sessions: CLAUDE.md or AGENTS.md, Projects, files. Handoff artifacts are documents one agent writes for the next to pick up. Two context strategies matter for long tasks: compaction summarizes the history in place, and a context reset starts a fresh agent with a structured handoff file. Anthropic's harness post found that models near a perceived context limit wrap up early, a behavior it calls "context anxiety," which is why long-running harnesses reset rather than compact indefinitely. Anatomy of an Agent Loop goes deeper.
The four multi-agent shapes
One agent is enough for most tasks. Reach for several when the work has independent parts that can run in parallel, when different parts need different tools or models, when a verbose sub-task would pollute the main agent's context, or when you want a separate evaluator. Here are the four shapes, each drawn once.
Sequential pipeline
Each stage's output is the next stage's input. Use it when the steps are genuinely ordered and quality improves through stages. Its weakness is latency and the way errors compound downstream.
Parallel with aggregation
Independent sub-tasks run at once and a final agent combines them. Use it when speed matters and the sub-tasks do not depend on each other. Its weakness is the aggregator, which must reconcile conflicting findings.
Hierarchical: orchestrator and subagents
A lead agent decomposes the goal, delegates to specialists with their own context windows, and integrates their reports. This is the shape behind Claude Code subagents. Use it to keep verbose research out of the main context and to give each specialist a narrow tool set. Its weakness is that the orchestrator only knows what the subagents report.
Peer team with shared state
Several agents pick tasks from a shared list and message each other directly, with no single orchestrator. This is the shape behind Claude Code agent teams and behind Anthropic's compiler experiment. Use it when the work is large and divisible and the agents need to coordinate on shared files. Its weakness is cost and coordination overhead.
First-party primitives in 2026
The old way to teach multi-agent systems was a CrewAI or LangGraph sample. The current way is to use what the harness provides. Claude Code's documentation (October 2026) describes five modes; three map directly onto the shapes above.
| Shape | Claude Code primitive | What the docs say | Reach for it when |
|---|---|---|---|
| Hierarchical | Subagents | Own context window; default 20 concurrent; up to 3 nesting layers; defined in .claude/agents/ | A sub-task is verbose or needs a narrow tool set |
| Peer team | Agent teams | Experimental, off by default; shared task list and inter-agent mailbox; about 7x the tokens of a standard session when teammates plan | Large divisible work on shared files, with a budget to match |
| Pipeline or parallel at scale | Dynamic workflows | Claude writes a JavaScript script that orchestrates dozens to hundreds of agents; default 16 concurrent; capped at 1,000 agents per run; flags runs over 25 agents or 1.5M projected tokens | Batch work across many files or records |
| Any, unattended | Background agents and cloud Projects | claude agents (research preview); cloud threads on Pro and Max | Work that should continue while you do something else |
A subagent is a markdown file with frontmatter. This one gives a security reviewer read-only tools:
---
name: security-reviewer
description: Reviews code changes for security vulnerabilities. Use before merging.
tools: Read, Grep, Glob
---
You are a senior security engineer. Review the changed files for injection
vulnerabilities, authentication flaws, secrets in code, and insecure data
handling. Report findings with file and line, severity, and a suggested fix.
Do not modify files.
Invoke it by asking: "use the security-reviewer subagent on the files I changed." The main conversation receives only the report. On the API side, Anthropic's Managed Agents offer the same hierarchical shape as a roster of worker agents, with the lead agent's "brain" decoupled from the sandbox "hands" that execute tools. OpenAI's Agents API and Google's Antigravity have their own subagent features (reported); the shapes transfer even when the names do not.
Case study: sixteen agents, one compiler
In February 2026 Anthropic reported building a roughly 100,000-line C compiler in Rust with sixteen parallel Claude instances over about two thousand sessions and two weeks, for around 20,000 dollars in API cost. There was no orchestrator; agents coordinated through git lock files on a shared task list, the peer-team shape above. The lessons generalize. Test quality dominated everything, because agents optimize for whatever the tests measure. Work had to be made divisible before parallelism helped. Specialized roles beat generalists. And "passing tests doesn't guarantee correct software": the compiler passed its suite and still needed human review of what the suite did not cover. The team also named two failure modes you will meet at smaller scale: context window pollution, where irrelevant results crowd out the task, and time blindness, where an agent has no sense of how long it has been working.
Anti-patterns
The ping-pong loop. Two agents hand work back and forth with no stop condition. One self-reported 2026 case ran for eleven days and cost about 47,000 dollars. Fix: a maximum iteration count, a completion condition (Claude Code's /goal evaluates one after every turn and stops after several turns without progress), and a hard budget flag.
Tool addiction. The agent calls ten tools to answer a question it already knows. Fix: narrow the tool list per agent and lower the effort setting for simple steps.
Over-planning. An hour of planning for a five-minute task. Fix: match plan depth to task size; skip Plan Mode for small edits.
Shared-context teams. Several agents reasoning in one context window, so each sees the others' noise. Fix: subagents with their own windows, and handoff files rather than long shared transcripts.
No evaluator. The generator grades its own work. Fix: a separate evaluator, deterministic checks, or a human at the gate.
Choosing a pattern
| Task | Pattern | Why |
|---|---|---|
| Research with adaptation | Single agent loop with verification | Needs to change course on findings |
| Long project with approval | Planning, then execution | You want to see the plan first |
| Quality-critical writing or code | Generator plus evaluator | Fresh-context critique catches what self-review misses |
| Verbose investigation | Hierarchical subagents | Keeps the main context clean |
| Large divisible codebase work | Peer agent team | Parallel work on shared files, if the budget allows |
| Hundreds of similar items | Dynamic workflow | Scripted orchestration with caps |
| Same steps every time, auditable | A workflow, not an agent | See When a Workflow Beats a Loop |
Key takeaways
- The agent loop is the base pattern; the harness around it, not the prompt, determines reliability.
- Planning, a separate evaluator, deterministic verification, and deliberate memory handling are the single-agent patterns worth learning.
- The four multi-agent shapes map to first-party primitives: subagents (hierarchical), agent teams (peer), dynamic workflows (pipeline and parallel at scale).
- Multi-agent systems cost more and coordinate badly without divisible work and strong tests. Start with one agent and add a second only for a reason you can name.
Next steps
- Continue to: Claude Code: Your AI Coding Agent
- For stop conditions, budgets, and context resets: Anatomy of an Agent Loop
- For the evaluator role as a method: Evals for Agents
- For containing what a team of agents can touch: Agent Safety and Guardrails