多 Agent 路由
你可以在 UI(Routing & Runtime)或 config.json 中配置 OpenClaw 风格的多 Agent 运行模式。
关键配置
agents.list:在同一个网关进程内运行多个常驻 Agentbindings:按channel + accountId (+peer)把入站消息路由到目标agentIdsession.dmScope:私聊会话隔离策略session.agentToAgent.maxPingPongTurns:限制 Agent 间 ping-pong 轮数
示例配置
json
{
"agents": {
"defaults": { "model": "openai/gpt-5.2-codex" },
"list": [
{ "id": "main", "default": true },
{ "id": "engineer", "workspace": "~/workspace-engineer", "model": "openai/gpt-5.2-codex" }
]
},
"bindings": [
{
"agentId": "engineer",
"match": {
"channel": "discord",
"accountId": "default",
"peer": { "kind": "channel", "id": "dev-room" }
}
}
],
"session": {
"dmScope": "per-account-channel-peer",
"agentToAgent": { "maxPingPongTurns": 0 }
}
}DM Scope 取值
⚠️
session.dmScope仅允许以下 4 个值:
| 值 | 隔离粒度 |
|---|---|
main | 所有私聊共享一个会话 |
per-peer | 每个对端一个会话 |
per-channel-peer | 每个渠道 + 对端一个会话 |
per-account-channel-peer | 账号 + 渠道 + 对端完全隔离 |
bindings 匹配语义
bindings 按数组顺序匹配,首个命中规则生效。
match.channel必填match.accountId:省略 = 仅匹配default;"*"= 匹配所有账号match.peer:省略 = 匹配全部 peer- 无匹配 = 回退到默认 Agent
推荐实践
- 保留
main作为兜底默认角色 - 按职责拆分专家 Agent(如
engineer、ops、support) - 用
bindings做按渠道/账号/群组的精细路由 - 多账号场景优先
dmScope="per-account-channel-peer" maxPingPongTurns先设0,确有需要再提高