Overview
Complex tasks often require different expertise. klaw supports multi-agent workflows where specialized agents collaborate, each contributing their unique capabilities. This guide covers patterns for effective multi-agent orchestration.Why Multi-Agent?
Single agents work well for focused tasks. But consider:| Task | Better Approach |
|---|---|
| ”Fix this bug” | Single agent (coder) |
| “Research best practices, implement them, then write docs” | Multi-agent workflow |
| ”Review PR for code quality, security, and performance” | Multiple specialized reviewers |
Orchestrator Routing
The simplest multi-agent pattern uses the orchestrator to route messages:Configure Orchestrator
Automatic Routing
Messages are automatically routed:Manual Routing
Override with@agent syntax:
Inline Delegation
Thedelegate tool lets a main agent spawn ephemeral sub-agents that execute immediately and return results. This is the primary mechanism for task decomposition within a single conversation.
Using the delegate Tool
- Sub-agents run inline — the main agent waits for the result
- Each sub-agent gets its own tool set (configurable via allowlist)
- Sub-agents can nest up to 3 levels deep
- 5-minute timeout per delegation
- Output truncated at 30,000 characters
In Practice
Persistent Agent Spawning
For long-lived agents that persist across conversations, useagent_spawn to create orchestrator bindings:
agent_spawn when you need agents that are routable via @agent syntax and persist beyond a single conversation. Use delegate when you need inline task execution within a conversation.
Workflow Patterns
Sequential Pipeline
Each agent’s output feeds the next:Parallel Execution
Independent tasks run simultaneously. With thedelegate tool, the LLM can issue multiple delegations in a single turn and they execute in parallel:
Supervisor Pattern
A coordinator agent manages workers:Creating Specialized Teams
Development Team
Research Team
DevOps Team
Namespace-Based Teams
Organize agents into namespaces for isolation:Communication Patterns
Shared Context via Workspace
Agents share knowledge through workspace files:Message Passing (Slack)
In Slack, agents can communicate via channels:Task Dependencies
Use cron or dispatch with dependencies:Best Practices
Define clear boundaries
Define clear boundaries
Each agent should have a specific, non-overlapping responsibility. Avoid agents that do “everything.”
Establish communication protocols
Establish communication protocols
Define how agents share information—workspace files, specific channels, or structured handoffs.
Verify handoffs
Verify handoffs
When one agent finishes, another should verify the output before continuing.
Monitor and adjust
Monitor and adjust
Track which patterns work well. Some tasks may be better with fewer, more capable agents.
Example: Full Feature Development
1. Create the Team
2. Configure Orchestrator
3. Execute the Workflow
Next Steps
Orchestrator
Deep dive into routing
Distributed Deployment
Scale multi-agent systems

