Broadcast Groups
状态: 实验性功能 版本: 2026.1.9 新增
概述
Broadcast Groups 让多个 Agent 可以同时处理和回复同一条消息。你可以创建专业的 Agent 团队,在一个 WhatsApp 群组或私信中协同工作——只需要一个手机号。
当前范围:仅支持 WhatsApp(web channel)。
Broadcast groups 在 channel allowlist 和群组激活规则之后评估。在 WhatsApp 群组中,这意味着当 OpenClaw 正常回复时才会触发广播(例如:被提及时,取决于你的群组设置)。
使用场景
1. 专业 Agent 团队
部署多个 Agent,每个负责单一、专注的职责:
Group: "Development Team"
Agents:
- CodeReviewer (reviews code snippets)
- DocumentationBot (generates docs)
- SecurityAuditor (checks for vulnerabilities)
- TestGenerator (suggests test cases)
每个 Agent 处理同一条消息,提供各自的专业视角。
2. 多语言支持
Group: "International Support"
Agents:
- Agent_EN (responds in English)
- Agent_DE (responds in German)
- Agent_ES (responds in Spanish)
3. 质量保证工作流
Group: "Customer Support"
Agents:
- SupportAgent (provides answer)
- QAAgent (reviews quality, only responds if issues found)
4. 任务自动化
Group: "Project Management"
Agents:
- TaskTracker (updates task database)
- TimeLogger (logs time spent)
- ReportGenerator (creates summaries)
配置
基础设置
添加一个顶层的 broadcast 配置段(和 bindings 同级)。键是 WhatsApp peer id:
- 群聊: group JID(例如
[email protected]) - 私信: E.164 电话号码(例如
+15551234567)
{
"broadcast": {
"[email protected]": ["alfred", "baerbel", "assistant3"]
}
}
结果: 当 OpenClaw 在这个聊天中回复时,会运行这三个 Agent。
处理策略
控制 Agent 如何处理消息:
Parallel(默认)
所有 Agent 同时处理:
{
"broadcast": {
"strategy": "parallel",
"[email protected]": ["alfred", "baerbel"]
}
}
Sequential
Agent 按顺序处理(一个等待前一个完成):
{
"broadcast": {
"strategy": "sequential",
"[email protected]": ["alfred", "baerbel"]
}
}
完整示例
{
"agents": {
"list": [
{
"id": "code-reviewer",
"name": "Code Reviewer",
"workspace": "/path/to/code-reviewer",
"sandbox": { "mode": "all" }
},
{
"id": "security-auditor",
"name": "Security Auditor",
"workspace": "/path/to/security-auditor",
"sandbox": { "mode": "all" }
},
{
"id": "docs-generator",
"name": "Documentation Generator",
"workspace": "/path/to/docs-generator",
"sandbox": { "mode": "all" }
}
]
},
"broadcast": {
"strategy": "parallel",
"[email protected]": ["code-reviewer", "security-auditor", "docs-generator"],
"[email protected]": ["support-en", "support-de"],
"+15555550123": ["assistant", "logger"]
}
}
工作原理
消息流程
- 收到消息 到达 WhatsApp 群组
- 广播检查: 系统检查 peer ID 是否在
broadcast中 - 如果在广播列表中:
- 所有列出的 Agent 处理该消息
- 每个 Agent 有自己的 session key 和隔离的上下文
- Agent 并行处理(默认)或顺序处理
- 如果不在广播列表中:
- 应用正常路由(第一个匹配的 binding)
注意: broadcast groups 不会绕过 channel allowlist 或群组激活规则(提及/命令等)。它们只改变消息符合处理条件时_运行哪些 Agent_。
Session 隔离
广播组中的每个 Agent 完全独立维护:
- Session keys(
agent:alfred:whatsapp:group:120363...vsagent:baerbel:whatsapp:group:120363...) - 对话历史(Agent 看不到其他 Agent 的消息)
- Workspace(如果配置了,使用独立的 sandbox)
- 工具访问权限(不同的 allow/deny 列表)
- 记忆/上下文(独立的 IDENTITY.md、SOUL.md 等)
- 群组上下文缓冲区(用于上下文的最近群组消息)是按 peer 共享的,所以所有广播 Agent 在触发时看到相同的上下文
这让每个 Agent 可以拥有:
- 不同的个性
- 不同的工具访问权限(例如:只读 vs. 读写)
- 不同的模型(例如:opus vs. sonnet)
- 不同的已安装 Skill
示例: 隔离的 Session
在群组 [email protected] 中,有 Agent ["alfred", "baerbel"]:
Alfred 的上下文:
Session: agent:alfred:whatsapp:group:[email protected]
History: [user message, alfred's previous responses]
Workspace: /Users/pascal/openclaw-alfred/
Tools: read, write, exec
Bärbel 的上下文:
Session: agent:baerbel:whatsapp:group:[email protected]
History: [user message, baerbel's previous responses]
Workspace: /Users/pascal/openclaw-baerbel/
Tools: read only
最佳实践
1. 保持 Agent 专注
设计每个 Agent 时给它单一、明确的职责:
{
"broadcast": {
"DEV_GROUP": ["formatter", "linter", "tester"]
}
}
✅ 好: 每个 Agent 只做一件事 ❌ 不好: 一个通用的 “dev-helper” Agent
2. 使用描述性名称
让每个 Agent 的功能一目了然:
{
"agents": {
"security-scanner": { "name": "Security Scanner" },
"code-formatter": { "name": "Code Formatter" },
"test-generator": { "name": "Test Generator" }
}
}
3. 配置不同的工具访问权限
只给 Agent 它需要的工具:
{
"agents": {
"reviewer": {
"tools": { "allow": ["read", "exec"] } // 只读
},
"fixer": {
"tools": { "allow": ["read", "write", "edit", "exec"] } // 读写
}
}
}
4. 监控性能
当有很多 Agent 时,考虑:
- 使用
"strategy": "parallel"(默认)提升速度 - 限制广播组为 5-10 个 Agent
- 为简单的 Agent 使用更快的模型
5. 优雅地处理失败
Agent 独立失败。一个 Agent 的错误不会阻塞其他 Agent:
Message → [Agent A ✓, Agent B ✗ error, Agent C ✓]
Result: Agent A 和 C 回复, Agent B 记录错误
兼容性
Provider
Broadcast groups 目前支持:
- ✅ WhatsApp(已实现)
- 🚧 Telegram(计划中)
- 🚧 Discord(计划中)
- 🚧 Slack(计划中)
Routing
Broadcast groups 与现有路由配合使用:
{
"bindings": [
{
"match": { "channel": "whatsapp", "peer": { "kind": "group", "id": "GROUP_A" } },
"agentId": "alfred"
}
],
"broadcast": {
"GROUP_B": ["agent1", "agent2"]
}
}
GROUP_A: 只有 alfred 回复(正常路由)GROUP_B: agent1 和 agent2 都回复(广播)
优先级: broadcast 优先于 bindings。
故障排除
Agent 没有回复
检查:
- Agent ID 存在于
agents.list中 - Peer ID 格式正确(例如
[email protected]) - Agent 不在 deny 列表中
调试:
tail -f ~/.openclaw/logs/gateway.log | grep broadcast
只有一个 Agent 回复
原因: Peer ID 可能在 bindings 中但不在 broadcast 中。
修复: 添加到 broadcast 配置或从 bindings 中移除。
性能问题
如果有很多 Agent 时很慢:
- 减少每个组的 Agent 数量
- 使用更轻量的模型(sonnet 而不是 opus)
- 检查 sandbox 启动时间
示例
示例 1: 代码审查团队
{
"broadcast": {
"strategy": "parallel",
"[email protected]": [
"code-formatter",
"security-scanner",
"test-coverage",
"docs-checker"
]
},
"agents": {
"list": [
{
"id": "code-formatter",
"workspace": "~/agents/formatter",
"tools": { "allow": ["read", "write"] }
},
{
"id": "security-scanner",
"workspace": "~/agents/security",
"tools": { "allow": ["read", "exec"] }
},
{
"id": "test-coverage",
"workspace": "~/agents/testing",
"tools": { "allow": ["read", "exec"] }
},
{ "id": "docs-checker", "workspace": "~/agents/docs", "tools": { "allow": ["read"] } }
]
}
}
用户发送: 代码片段 回复:
- code-formatter: “Fixed indentation and added type hints”
- security-scanner: “⚠️ SQL injection vulnerability in line 12”
- test-coverage: “Coverage is 45%, missing tests for error cases”
- docs-checker: “Missing docstring for function
process_data”
示例 2: 多语言支持
{
"broadcast": {
"strategy": "sequential",
"+15555550123": ["detect-language", "translator-en", "translator-de"]
},
"agents": {
"list": [
{ "id": "detect-language", "workspace": "~/agents/lang-detect" },
{ "id": "translator-en", "workspace": "~/agents/translate-en" },
{ "id": "translator-de", "workspace": "~/agents/translate-de" }
]
}
}
API 参考
配置结构
interface OpenClawConfig {
broadcast?: {
strategy?: "parallel" | "sequential";
[peerId: string]: string[];
};
}
字段说明
strategy(可选): 如何处理 Agent"parallel"(默认): 所有 Agent 同时处理"sequential": Agent 按数组顺序处理
[peerId]: WhatsApp group JID、E.164 号码或其他 peer ID- 值: 应该处理消息的 Agent ID 数组
限制
- 最大 Agent 数: 没有硬性限制,但 10+ 个 Agent 可能会慢
- 共享上下文: Agent 看不到彼此的回复(设计如此)
- 消息顺序: 并行回复可能以任意顺序到达
- 速率限制: 所有 Agent 都计入 WhatsApp 速率限制
未来增强
计划中的功能:
- 共享上下文模式(Agent 可以看到彼此的回复)
- Agent 协调(Agent 可以互相发信号)
- 动态 Agent 选择(根据消息内容选择 Agent)
- Agent 优先级(某些 Agent 先于其他 Agent 回复)