Multi-Agent Orchestration: Worked Example — Agentic Architecture & Orchestration (Claude Certified Architect)
Multi-Agent Orchestration: A Worked Example Using the Claude Agent SDK This worked example demonstrates how to design and implement a multi-agent...
Multi-Agent Orchestration: A Worked Example Using the Claude Agent SDK
This worked example demonstrates how to design and implement a multi-agent orchestration system using the Claude Agent SDK, focusing on the coordinator-subagent pattern. We will walk through a realistic scenario where a Travel Planning Assistant autonomously coordinates multiple specialized subagents to deliver a comprehensive travel itinerary.
Scenario Overview
The Travel Planning Assistant needs to:
- Gather user preferences and constraints
- Query flight options
- Find hotel accommodations
- Recommend local activities
- Compile and present a final itinerary
Each of these tasks is delegated to a dedicated subagent, coordinated by a central agent that manages context passing, task decomposition, and workflow orchestration.
Step 1: Defining the Coordinator and SubagentsThe Coordinator Agent acts as the main orchestrator. It spawns and manages the lifecycle of three subagents:
- Flight Agent: Handles flight search and filtering
- Hotel Agent: Manages hotel availability and booking options
- Activities Agent: Suggests local attractions and experiences
Each subagent receives relevant context and returns structured results to the coordinator.
Step 2: Task Decomposition Strategy
The coordinator decomposes the overall travel planning task into discrete subtasks:
- Collect user preferences (dates, budget, interests)
- Spawn subagents with tailored prompts and context
- Aggregate subagent outputs
- Generate a consolidated itinerary
This decomposition ensures modularity and parallel execution where possible.
Step 3: Implementing Context Passing and Subagent Spawning
Using the Claude Agent SDK, the coordinator creates subagent instances with context objects encapsulating user inputs and prior responses. For example:
- Flight Agent context: travel dates, departure city, destination
- Hotel Agent context: destination, budget, preferred amenities
- Activities Agent context: destination, interests, trip duration
The SDK's spawnSubagent() method is used to instantiate each subagent asynchronously, enabling concurrent processing.
Step 4: Applying SDK Hooks for Tool Call Interception
To enhance control, the coordinator implements SDK hooks that intercept subagent tool calls, such as API requests or database queries. This allows:
- Logging and monitoring of external calls
- Validation and sanitization of inputs/outputs
- Dynamic modification of tool parameters based on runtime conditions
For example, the Flight Agent’s API call to an airline database can be intercepted to enforce rate limits or cache results.
Step 5: Managing Multi-Step Workflows with Programmatic Enforcement
The coordinator enforces a multi-step workflow by awaiting subagent completions and validating outputs before proceeding. If a subagent returns incomplete or inconsistent data, the coordinator can:
- Request clarification or re-execution from the subagent
- Fork the session to explore alternative options
- Resume from a saved state after external interruptions
This programmatic control ensures robustness and accuracy in the final itinerary.
Step 6: Session State Management Including Resumption and Forking
The Claude Agent SDK supports session state management, enabling the coordinator to:
- Resume workflows after interruptions by restoring context and subagent states
- Fork sessions to explore different travel options in parallel without losing prior progress
For example, if the user changes travel dates mid-process, the coordinator forks the session to re-run flight and hotel searches with updated parameters.
Worked Example Summary
Problem: Design a multi-agent orchestration system for a Travel Planning Assistant using the Claude Agent SDK.
Solution Steps:
- Define a coordinator agent and specialized subagents (Flight, Hotel, Activities).
- Decompose the task into subtasks and assign context to each subagent.
- Spawn subagents asynchronously with spawnSubagent().
- Implement SDK hooks to intercept and manage tool calls.
- Enforce multi-step workflows by validating subagent outputs and managing retries.
- Use session state management to enable resumption and forking of workflows.
This approach leverages the Claude Agent SDK’s capabilities to build a robust, modular, and autonomous multi-agent system tailored for complex task orchestration.
For more detailed technical references and SDK usage, consult the official Claude Certified Architect Foundation materials and the Claude Agent SDK documentation.
More in this topic
Ready to test your knowledge?
Put what you've learned into practice with a quick quiz and track your progress.
Test your knowledge →