Multi-Agent Routing
OpenClaw supports routing different channels, accounts, and users to isolated agent instances, each with their own workspace, session state, and configuration.Overview
Multi-agent routing enables:- Workspace isolation — Separate working directories per agent
- Session isolation — Independent conversation history
- Model customization — Different models per agent
- Specialized agents — Code, creative writing, research, etc.
- Team workspaces — Route teams/channels to dedicated agents
Architecture
- Runs in the same gateway process
- Has isolated workspace and sessions
- Can use different models
- Routes based on channel, account, or peer
Configuration
Define Agents
Route Channels to Agents
Routing Match Criteria
Routes can match on:| Field | Description | Example |
|---|---|---|
channel | Channel type | discord, telegram, slack, whatsapp |
accountId | Account identifier | main, work, personal |
groupId | Group/channel ID | Discord channel ID, Slack channel ID |
peerId | User/peer identifier | Telegram user ID, WhatsApp number |
agent | Target agent | main, code-assistant, creative |
Session Scoping
Control session isolation withsession.dmScope:
| Mode | Description | Use Case |
|---|---|---|
main | All DMs share main session | Single-user, simple setup |
per-channel-peer | Separate session per (channel, peer) | Multi-user, per-channel isolation |
per-account-channel-peer | Separate session per (account, channel, peer) | Multi-account channels |
src/commands/doctor-security.ts:116-122.
Use Cases
Team Workspaces
Route different teams to isolated agents:Specialized Agents
Create domain-specific assistants:Personal vs Work
Separate personal and work contexts:Multi-Account Routing
Route multiple accounts to different agents:CLI Commands
List Agents
Send to Specific Agent
Check Agent Workspace
Workspace Management
Workspace Structure
Each agent has an isolated workspace:Initialize Agent Workspace
Backup Agent Data
Advanced Configuration
Per-Agent Model Settings
Per-Agent Tools
Enable/disable tools per agent:Per-Agent Hooks
Customize hooks per agent:Monitoring
View Agent Activity
Debug Routing
Troubleshooting
Agent not routing correctly
Agent not routing correctly
Problem: Messages going to wrong agent.Debug:
Agent workspace not found
Agent workspace not found
Problem: Agent can’t access workspace files.Fix:
Session state not isolated
Session state not isolated
Problem: Agents sharing session state.Fix:
Routing rules not matching
Routing rules not matching
Problem: Rules not matching expected traffic.Debug:
Best Practices
Next Steps
Security Guide
Secure multi-agent setups with allowlists
Deployment
Deploy multi-agent gateway to production
Configuration
Advanced gateway configuration
Sessions
Understand session management

