Skip to content

廣播群組

狀態: 實驗性
版本: 新增於 2026.1.9

廣播群組讓多個代理能夠同時處理並回應同一則訊息。這讓您可以建立專業的代理團隊,在單一 WhatsApp 群組或私訊中協作——全部使用同一個電話號碼。

目前範圍:僅限 WhatsApp(網頁頻道)。

廣播群組是在頻道允許清單和群組啟用規則之後進行評估。在 WhatsApp 群組中,這意味著廣播會在 OpenClaw 通常會回覆時發生(例如:在被提及時,視您的群組設定而定)。

部署多個具有獨立、專注職責的代理:

Group: "Development Team"
Agents:
- CodeReviewer (reviews code snippets)
- DocumentationBot (generates docs)
- SecurityAuditor (checks for vulnerabilities)
- TestGenerator (suggests test cases)

每個代理處理相同的訊息,並提供其專業的觀點。

Group: "International Support"
Agents:
- Agent_EN (responds in English)
- Agent_DE (responds in German)
- Agent_ES (responds in Spanish)
Group: "Customer Support"
Agents:
- SupportAgent (provides answer)
- QAAgent (reviews quality, only responds if issues found)
Group: "Project Management"
Agents:
- TaskTracker (updates task database)
- TimeLogger (logs time spent)
- ReportGenerator (creates summaries)

新增一個頂層 broadcast 部分(在 bindings 旁邊)。鍵值為 WhatsApp 對端 ID:

  • 群組聊天:群組 JID(例如 [email protected]
  • 私訊:E.164 電話號碼(例如 +15551234567
{
"broadcast": {
"[email protected]": ["alfred", "baerbel", "assistant3"]
}
}

結果: 當 OpenClaw 在此聊天中回覆時,它將執行所有三個代理。

控制代理如何處理訊息:

所有代理同時處理:

{
"broadcast": {
"strategy": "parallel",
"[email protected]": ["alfred", "baerbel"]
}
}

代理依順序處理(一個等待前一個完成):

{
"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"]
}
}
  1. 傳入訊息 抵達 WhatsApp 群組
  2. 廣播檢查:系統檢查對端 ID 是否位於 broadcast
  3. 若在廣播清單中
    • 所有列出的代理處理該訊息
    • 每個代理都有自己的會話金鑰和隔離的上下文
    • 代理並行處理(預設)或循序處理
  4. 若不在廣播清單中
    • 套用一般路由(第一個符合的綁定)

注意:廣播群組不會繞過頻道允許清單或群組啟用規則(提及/指令等)。它們僅在訊息符合處理資格時改變 執行哪些代理

廣播群組中的每個代理都維護完全獨立的:

  • Session keys (agent:alfred:whatsapp:group:120363... vs agent:baerbel:whatsapp:group:120363...)
  • Conversation history (agent doesn’t see other agents’ messages)
  • Workspace (separate sandboxes if configured)
  • Tool access (different allow/deny lists)
  • Memory/context (separate IDENTITY.md, SOUL.md, etc.)
  • Group context buffer (recent group messages used for context) is shared per peer, so all broadcast agents see the same context when triggered

這允許每個代理擁有:

  • 不同的個性
  • Different tool access (e.g., read-only vs. read-write)
  • Different models (e.g., opus vs. sonnet)
  • 安裝不同的技能

In group [email protected] with agents ["alfred", "baerbel"]:

Alfred’s context:

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’s context:

Session: agent:baerbel:whatsapp:group:[email protected]
History: [user message, baerbel's previous responses]
Workspace: /Users/pascal/openclaw-baerbel/
Tools: read only

Design each agent with a single, clear responsibility:

{
"broadcast": {
"DEV_GROUP": ["formatter", "linter", "tester"]
}
}

Good: Each agent has one job
Bad: One generic “dev-helper” agent

Make it clear what each agent does:

{
"agents": {
"security-scanner": { "name": "Security Scanner" },
"code-formatter": { "name": "Code Formatter" },
"test-generator": { "name": "Test Generator" }
}
}

Give agents only the tools they need:

{
"agents": {
"reviewer": {
"tools": { "allow": ["read", "exec"] } // Read-only
},
"fixer": {
"tools": { "allow": ["read", "write", "edit", "exec"] } // Read-write
}
}
}

With many agents, consider:

  • Using "strategy": "parallel" (default) for speed
  • Limiting broadcast groups to 5-10 agents
  • Using faster models for simpler agents

Agents fail independently. One agent’s error doesn’t block others:

Message → [Agent A ✓, Agent B ✗ error, Agent C ✓]
Result: Agent A and C respond, Agent B logs error

Broadcast groups currently work with:

  • ✅ WhatsApp (implemented)
  • 🚧 Telegram (planned)
  • 🚧 Discord (planned)
  • 🚧 Slack (planned)

Broadcast groups work alongside existing routing:

{
"bindings": [
{
"match": { "channel": "whatsapp", "peer": { "kind": "group", "id": "GROUP_A" } },
"agentId": "alfred"
}
],
"broadcast": {
"GROUP_B": ["agent1", "agent2"]
}
}
  • GROUP_A: Only alfred responds (normal routing)
  • GROUP_B: agent1 AND agent2 respond (broadcast)

Precedence: broadcast takes priority over bindings.

Check:

  1. Agent IDs exist in agents.list
  2. Peer ID format is correct (e.g., [email protected])
  3. Agents are not in deny lists

Debug:

Terminal window
tail -f ~/.openclaw/logs/gateway.log | grep broadcast

原因: Peer ID 可能位於 bindings 中,但不在 broadcast 中。

修復: 將其新增到廣播設定或從綁定中移除。

如果代理程式多時速度變慢:

  • 減少每個群組的代理程式數量
  • 使用較輕量的模型(sonnet 而非 opus)
  • 檢查沙箱啟動時間
{
"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: “已修正縮排並新增型別提示”
  • security-scanner: “⚠️ 第 12 行有 SQL 注入漏洞”
  • test-coverage: “覆蓋率為 45%,缺少錯誤情況的測試”
  • docs-checker: “函式 process_data 缺少文件字串”
{
"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" }
]
}
}
interface OpenClawConfig {
broadcast?: {
strategy?: "parallel" | "sequential";
[peerId: string]: string[];
};
}
  • strategy (選用):如何處理代理程式
    • "parallel" (預設):所有代理程式同時處理
    • "sequential":代理程式依陣列順序處理
  • [peerId]:WhatsApp 群組 JID、E.164 號碼或其他 Peer ID
    • 值:應處理訊息的代理程式 ID 陣列
  1. 最大代理程式數: 沒有硬性限制,但 10 個以上的代理程式可能會很慢
  2. 共享上下文: 代理程式看不到彼此的回應(依照設計)
  3. 訊息排序: 平行回應可能以任何順序抵達
  4. 速率限制: 所有代理程式都計入 WhatsApp 速率限制

計畫功能:

  • 共享上下文模式(代理程式能看到彼此的回應)
  • 代理程式協調(代理程式可以互相發送訊號)
  • 動態代理程式選擇(根據訊息內容選擇代理程式)
  • 代理程式優先順序(部分代理程式會先回應)