多智能体路由
OpenClaw 支持多智能体配置,将不同的消息路由到不同的智能体。
概述
多智能体路由允许:
- 不同用户使用不同智能体
- 不同通道使用不同智能体
- 不同任务使用不同模型
配置示例
json
{
"agents": {
"entries": {
"main": {
"workspace": "~/.openclaw/workspace",
"model": {
"primary": "anthropic/claude-sonnet-4-20250514"
}
},
"coding": {
"workspace": "~/.openclaw/workspace-coding",
"model": {
"primary": "anthropic/claude-opus-4-20250514"
}
}
},
"routing": [
{
"match": {
"channel": "telegram",
"accountId": "coding-bot"
},
"agentId": "coding"
}
]
}
}路由规则
路由可以基于:
- 通道 - WhatsApp、Telegram、Discord 等
- 账户 - 通道账户 ID
- 发送者 - 用户 ID 或电话号码
- 群组 - 群组 ID
添加智能体
bash
# 交互式添加
openclaw agents add
# 带参数添加
openclaw agents add coding --workspace ~/coding-workspace --model anthropic/claude-opus-4-20250514
# 绑定到通道
openclaw agents add work --bind telegram:work-bot --bind discord:work列出智能体
bash
# 列出所有智能体
openclaw agents list
# 显示绑定
openclaw agents list --bindings使用场景
按用户分离
不同用户使用独立的工作区和会话:
json
{
"routing": [
{
"match": { "sender": "+15551234567" },
"agentId": "user-alice"
},
{
"match": { "sender": "+15559876543" },
"agentId": "user-bob"
}
]
}按任务分离
聊天和编程使用不同模型:
json
{
"routing": [
{
"match": { "channel": "telegram", "accountId": "chat" },
"agentId": "fast-chat"
},
{
"match": { "channel": "telegram", "accountId": "code" },
"agentId": "opus-coding"
}
]
}