Multi-Agent Routing
Deploy specialized AI agents for different tasks.
Overview
Multi-agent routing allows you to:
- Use different AI models for different tasks
- Route complex tasks to specialized agents
- Spawn sub-agents for parallel work
- Optimize costs with model selection
Agent Architecture
┌─────────────────────────────────────────┐
│ Main Agent │
│ (Receives all incoming messages) │
└─────────────┬───────────────────────────┘
│
┌─────────┼─────────┐
▼ ▼ ▼
┌───────┐ ┌───────┐ ┌───────┐
│Coder │ │Research│ │Chat │
│Agent │ │Agent │ │Agent │
└───────┘ └───────┘ └───────┘Configuration
Define Agents
json
{
"agents": {
"main": {
"model": "claude-3-5-sonnet",
"description": "Primary assistant"
},
"coder": {
"model": "gpt-4-codex",
"description": "Code generation and review"
},
"research": {
"model": "gpt-4-turbo",
"description": "Research and analysis"
}
}
}Routing Rules
json
{
"routing": {
"rules": [
{
"pattern": "write.*code|debug|refactor",
"agent": "coder"
},
{
"pattern": "research|search|analyze",
"agent": "research"
}
]
}
}Sub-Agent Spawning
Spawn agents dynamically for complex tasks:
bash
# Spawn a research agent
openclaw agent spawn --task "Research AI trends" --model "gpt-4-turbo"
# Spawn a coding agent
openclaw agent spawn --task "Refactor this module" --model "gpt-4-codex"Use Cases
Development Workflow
- Main agent receives request
- Routes coding tasks to coder agent
- Coder agent uses specialized model
- Results returned to main thread
Research Tasks
- Main agent identifies research need
- Spawns research agent with web tools
- Research agent compiles findings
- Main agent summarizes for user
Best Practices
- Keep main agent simple - Use for routing only
- Specialize agents - One task type per agent
- Monitor costs - Different models have different prices
- Test routing - Ensure tasks go to correct agents
Learn More
See Skills System to create custom agent behaviors.