Multi-Agent
Multi-agent orchestration uses a coordinating agent that delegates work to specialist agents. Unlike routing (which classifies once and calls one handler), the orchestrator runs a reasoning loop: it may call multiple specialists across multiple iterations, passing results between them, until the overall goal is met.
Each specialist is a separate durable task with its own prompt, tools, timeout, and retry settings. The orchestrator’s LLM decides which specialist to call next based on the accumulated context.
When to use
| Scenario | Fit |
|---|---|
| Complex tasks needing different expertise (research + code + writing) | Good: each specialist focuses on one domain |
| Customer service with support, sales, and billing specialists | Good: orchestrator picks the right expert per turn |
| Tasks where output from one specialist feeds the next | Good: orchestrator passes context between calls |
| Simple tasks a single agent can handle end-to-end | Skip: orchestration overhead isn’t worth it |
| Specialists always run in a fixed sequence | Use LLM Pipelines instead |
How it maps to Hatchet
The orchestrator is a durable task running a reasoning loop via child spawning. Each specialist is a standalone durable task spawned as a child run. The orchestrator’s LLM returns structured tool calls, and each tool name maps to a specialist task.
Because each specialist call is a child run, the orchestrator’s slot is freed while specialists execute. If the orchestrator dies mid-loop, it resumes from the last checkpoint without re-running completed specialist calls.
Step-by-step walkthrough
Define the specialist tasks
Each specialist is a standalone durable task with its own prompt and timeout. They run independently and can be reused across different orchestrators.
Orchestrator loop
The orchestrator runs a reasoning loop: call LLM, parse tool choice, spawn specialist, observe result, repeat. Context accumulates across iterations so later specialist calls have full history.
Run the worker
Register all specialists and the orchestrator, then start the worker.
Always set a max iteration count and execution timeout on the orchestrator. Without bounds, the loop can call specialists indefinitely.
Multi-agent vs. routing
| Multi-agent | Routing | |
|---|---|---|
| Specialist calls | Multiple, across loop iterations | One per request |
| Orchestration | Reasoning loop, LLM decides next step dynamically | Classify once, route once |
| Use when | Task needs multiple types of expertise | Task fits a single specialist |
Related Patterns
Multi-agent is a reasoning loop where “tools” are specialist durable tasks instead of API calls.
Reasoning LoopClassify once and route to one handler. Multi-agent loops and may call many.
RoutingWhen multiple specialists can work independently, spawn them in parallel within a single iteration.
ParallelizationThe Hatchet primitive used to spawn specialist tasks from the orchestrator.
Child SpawningNext Steps
- Durable Task Execution: understand checkpointing and replay for the orchestrator
- Child Spawning: spawn specialist tasks from the orchestrator loop
- Timeouts: set execution timeouts on the orchestrator and each specialist
- Concurrency Control: limit how many orchestrator runs execute in parallel