DEV Community

Sangmin Lee
Sangmin Lee

Posted on • Originally published at claudeguide.io

How to Build a Multi-Agent System with Claude Agent SDK

Originally published at claudeguide.io/multi-agent-claude-sdk

How to Build a Multi-Agent System with Claude Agent SDK

A multi-agent system with the Anthropic Claude SDK is an orchestrator model that spawns one or more subagent loops — each running its own tool-call cycle — then aggregates the results. You implement this entirely with the standard anthropic Python package: no special framework is required. This guide shows a complete research pipeline from scratch in 2026.

Prerequisites: Python 3.11+, anthropic package installed, ANTHROPIC_API_KEY set. If you haven't built a single-agent loop yet, start with the Claude Agent SDK quickstart first.


What you're building

A research pipeline where:

  1. An orchestrator (claude-sonnet-4-6) receives a topic and decomposes it into three parallel sub-queries.
  2. Three research subagents (claude-haiku-4-5) each run a search loop in parallel using asyncio.
  3. A synthesis agent (claude-sonnet-4-6) combines the three research reports into a final answer.

This maps to a real production pattern: companies running Claude-based research assistants use exactly this shape — parallel specialised agents feeding one synthesis layer — to get a 4x wall-clock speedup over sequential single-agent runs (Anthropic multi-agent blog, April 2026).


Architecture overview

User Query
    │
    ▼
┌──────────────────┐
│  Orchestrator    │  claude-sonnet-4-6  ($3/$15 per 1M tokens)
│  (decompose)     │
└──────┬───────────┘
       │ spawns 3 parallel tasks
       ▼
┌──────┐  ┌──────┐  ┌──────┐
│ R-A  │  │ R-B  │  │ R-C  │  claude-haiku-4-5  ($1/$5 per 1M tokens)
│search│  │search│  │search│  (each runs its own tool-call loop)
└──────┘  └──────┘  └──────┘
       │ results
       ▼
┌──────────────────┐
│  Synthesis       │  claude-sonnet-4-6
│  Agent           │
└──────────────────┘
       │
       ▼
Final Answer
Enter fullscreen mode Exit fullscreen mode

The cost asymmetry is intentional: Haiku is 3× cheaper per token than Sonnet for the retrieval-heavy subagent work, while Sonnet handles the reasoning-heavy orchestration and synthesis.


Step 1: Install dependencies

pip install anthropic
export ANTHROPIC_API_KEY=sk-ant-your-key-here
Enter fullscreen mode Exit fullscreen mode

The entire system uses only the standard anthropic package. No LangChain, no AutoGen, no additional dependencies.


Step 2: Define the search tool

Every research agent needs at least one tool — a web or knowledge-base search. In production, swap mock_search for your preferred search API (Brave, Serper, or Exa).


python
import anthropic
import asyncio
import json
import time
from dataclasses import dataclass

client = anthropic.Anthropic()

SEARCH_TOOL = {
    "name": "web_search",
    "description": (
        "Search the web for information on a topic. "
        "Use multiple targeted queries to gather thorough coverage."
    ),
    "input_schema": {
        "type": "object",
        "properties": {
            "query": {
                "type": "string",
                "description": "The specific search query to execute",
            }
        },
        "required": ["query"],
    },
}


def mock_search(query: str) -

Complete, runnable Python and TypeScript code throughout.

[→ Get Agent SDK Cookbook — $49](https://shoutfirst.gumroad.com/l/ogxhmy?utm_source=claudeguide&utm_medium=article&utm_campaign=multi-agent-claude-sdk)

*30-day money-back guarantee. Instant download.*
Enter fullscreen mode Exit fullscreen mode

Top comments (0)