广播群组
状态: 实验性功能
版本: 于 2026.1.9 版本新增
概述
广播群组允许多个智能体同时处理并响应同一条消息。这使你能够在单个 WhatsApp 群组或私信中创建协同工作的专业智能体团队——全部使用同一个手机号码。
当前范围:仅限 WhatsApp(web 渠道)。
广播群组在渠道白名单和群组激活规则之后进行评估。在 WhatsApp 群组中,这意味着广播会在 OpenClaw 正常回复时发生(例如:被提及时,具体取决于你的群组设置)。
使用场景
1. 专业智能体团队
部署多个具有原子化、专注职责的智能体:
Group: "Development Team"
Agents:
- CodeReviewer (reviews code snippets)
- DocumentationBot (generates docs)
- SecurityAuditor (checks for vulnerabilities)
- TestGenerator (suggests test cases)
每个智能体处理相同的消息并提供其专业视角。
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:
- 群聊:群组 JID(例如
120363403215116621@g.us) - 私信:E.164 格式的电话号码(例如
+15551234567)
{
"broadcast": {
"120363403215116621@g.us": ["alfred", "baerbel", "assistant3"]
}
}
结果: 当 OpenClaw 在此聊天中回复时,将运行所有三个智能体。
处理策略
控制智能体如何处理消息:
并行(默认)
所有智能体同时处理:
{
"broadcast": {
"strategy": "parallel",
"120363403215116621@g.us": ["alfred", "baerbel"]
}
}
顺序
智能体按顺序处理(后一个等待前一个完成):
{
"broadcast": {
"strategy": "sequential",
"120363403215116621@g.us": ["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",
"120363403215116621@g.us": ["code-reviewer", "security-auditor", "docs-generator"],
"120363424282127706@g.us": ["support-en", "support-de"],
"+15555550123": ["assistant", "logger"]
}
}
工作原理
消息流程
- 接收消息 到达 WhatsApp 群组
- 广播检查:系统检查 peer ID 是否在
broadcast中 - 如果在广播列表中:
- 所有列出的智能体处理该消息
- 每个智能体有自己的会话键和隔离的上下文
- 智能体并行处理(默认)或顺序处理
- 如果不在广播列表中:
- 应用正常路由(第一个匹配的绑定)
注意:广播群组不会绕过渠道白名单或群组激活规则(提及/命令等)。它们只改变消息符合处理条件时运行哪些智能体。
会话隔离
广播群组中的每个智能体完全独立维护:
- 会话键(
agent:alfred:whatsapp:group:120363...vsagent:baerbel:whatsapp:group:120363...) - 对话历史(智能体看不到其他智能体的消息)
- 工作空间(如果配置了则使用独立的沙箱)
- 工具访问权限(不同的允许/拒绝列表)
- 记忆/上下文(独立的 IDENTITY.md、SOUL.md 等)
- 群组上下文缓冲区(用于上下文的最近群组消息)按 peer 共享,因此所有广播智能体在被触发时看到相同的上下文
这允许每个智能体拥有:
- 不同的个性
- 不同的工具访问权限(例如只读 vs 读写)
- 不同的模型(例如 opus vs sonnet)
- 不同的已安装 Skills
示例:隔离的会话
在群组 120363403215116621@g.us 中,智能体为 ["alfred", "baerbel"]:
Alfred 的上下文:
Session: agent:alfred:whatsapp:group:120363403215116621@g.us
History: [user message, alfred's previous responses]
Workspace: /Users/pascal/openclaw-alfred/
Tools: read, write, exec
Bärbel 的上下文:
Session: agent:baerbel:whatsapp:group:120363403215116621@g.us
History: [user message, baerbel's previous responses]
Workspace: /Users/pascal/openclaw-baerbel/
Tools: read only
最佳实践
1. 保持智能体专注
将每个智能体设计为具有单一、明确的职责:
{
"broadcast": {
"DEV_GROUP": ["formatter", "linter", "tester"]
}
}
✅ 好的做法: 每个智能体只有一个任务
❌ 不好的做法: 一个通用的"dev-helper"智能体
2. 使用描述性名称
明确每个智能体的功能:
{
"agents": {
"security-scanner": { "name": "Security Scanner" },
"code-formatter": { "name": "Code Formatter" },
"test-generator": { "name": "Test Generator" }
}
}
3. 配置不同的工具访问权限
只给智能体提供它们需要的工具:
{
"agents": {
"reviewer": {
"tools": { "allow": ["read", "exec"] } // Read-only
},
"fixer": {
"tools": { "allow": ["read", "write", "edit", "exec"] } // Read-write
}
}
}
4. 监控性能
当有多个智能体时,请考虑:
- 使用
"strategy": "parallel"(默认)以提高速度 - 将广播群组限制在 5-10 个智能体
- 为较简单的智能体使用较快的模型
5. 优雅地处理失败
智能体独立失败。一个智能体的错误不会阻塞其他智能体:
Message → [Agent A ✓, Agent B ✗ error, Agent C ✓]
Result: Agent A and C respond, Agent B logs error
兼容性
提供商
广播群组目前支持:
- ✅ WhatsApp(已实现)
- 🚧 Telegram(计划中)
- 🚧 Discord(计划中)
- 🚧 Slack(计划中)
路由
广播群组与现有路由一起工作:
{
"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。
故障排除
智能体不响应
检查:
- 智能体 ID 存在于
agents.list中 - Peer ID 格式正确(例如
120363403215116621@g.us) - 智能体不在拒绝列表中
调试:
tail -f ~/.openclaw/logs/gateway.log | grep broadcast
只有一个智能体响应
原因: Peer ID 可能在 bindings 中但不在 broadcast 中。
修复: 添加到广播配置或从绑定中移除。
性能问题
如果智能体较多时速度较慢:
- 减少每个群组的智能体数量
- 使用较轻的模型(sonnet 而非 opus)
- 检查沙箱启动时间