Agent Swarm Kit
Get multiple AI agents working together in the same Discord channel — solving problems faster than any single agent could alone.
What This Does
Sets up a "swarming" pattern where two or more OpenClaw agents collaborate in real-time on a shared channel. One agent finds the root cause, the other validates and patches. They hand off to each other naturally using @mentions.
This isn't theoretical — it emerged from running two Opus models on the same issue and watching them solve it in 5 minutes instead of 20+.
How It Works
The Pattern
- 1. A human posts a problem in the swarming channel, @mentioning both agents
- Both agents see the message and respond with their analysis
- When one agent has new information, they @mention the other to hand off
- Back and forth until they converge on a solution
- Final summary posted, conversation ends naturally
Why It's Fast
- - Different contexts: Each agent brings a different perspective (different session history)
- Parallel analysis: Both start working simultaneously
- Cross-validation: One agent's finding gets immediately checked by the other
- No single-agent blind spots: If one misses something, the other catches it
Setup Guide
Step 1: Create the Swarming Channel
Create a dedicated Discord channel (e.g., #swarming) for multi-agent collaboration.
Step 2: Configure Both Agents
Both agents need:
- -
requireMention: true on the swarming channel - Different
mentionPatterns (each agent's own bot ID) - Their own Discord bot accounts (separate bot tokens)
Agent A config (Mini 1 — openclaw.json):
CODEBLOCK0
Agent B config (same pattern, different gateway/Mini).
Step 3: Loop Prevention Rules
Add these to both agents' SOUL.md files:
CODEBLOCK1
Step 4: Multi-Gateway Routing (Critical)
If both agents run on the same gateway (same Mini), you need:
- - Separate Discord accounts (separate bot tokens) for each agent
- Each account bound to a specific agent ID via
accountId in the agent config - Without this, both agents receive every message and the wrong one may respond
If agents are on different gateways (different Minis), this is automatic — each gateway only has its own agents.
When to Swarm
Good for swarming:
- - Complex debugging (config issues, multi-layer problems)
- Architecture decisions (two perspectives better than one)
- Research synthesis (different angles on same topic)
- Code review (one checks logic, other checks edge cases)
Not worth swarming:
- - Simple tasks (one agent is enough)
- Routine maintenance (use a single cheaper model)
- Anything with a clear, known procedure
Cost Considerations
Two Opus calls per exchange instead of one. But:
- - Problems solve 2-4x faster
- Fewer wrong turns (cross-validation catches mistakes early)
- Net token usage often lower because you avoid long single-agent spirals
For cost optimization, you can swarm Opus + Sonnet instead of Opus + Opus. The Sonnet agent handles validation while Opus does the heavy thinking.
Real Example
Two Opus agents were debugging an OpenClaw config routing issue. Agent A (Harrison) researched the channel whitelist config. Agent B (Prometheus) found the root cause — a missing account binding — and patched it. Total time: 5 minutes. Single agent estimate: 20+ minutes.
The key insight: they attacked the problem from different angles simultaneously. Harrison looked at the channel config layer while Prometheus looked at the account binding layer. Neither would have found both issues as fast alone.
Files Included
- -
SKILL.md — This file (setup guide + patterns) - INLINECODE5 — Copy-paste rules for agent SOUL.md files
- INLINECODE6 — Example OpenClaw config snippets
Agent Swarm Kit
让多个AI代理在同一个Discord频道中协同工作——比任何单个代理独自解决问题的速度更快。
功能概述
建立一种群集模式,让两个或更多OpenClaw代理在共享频道上实时协作。一个代理查找根本原因,另一个代理验证并修补。它们通过@提及自然地相互交接。
这并非理论设想——它源于让两个Opus模型处理同一个问题,并观察到它们在5分钟内解决,而非20分钟以上。
工作原理
模式流程
- 1. 用户在群集频道中发布问题,@提及两个代理
- 两个代理都看到消息并回复各自的分析
- 当一个代理获得新信息时,@提及另一个代理进行交接
- 反复交替,直到它们达成解决方案
- 发布最终总结,对话自然结束
为何高效
- - 不同上下文:每个代理带来不同视角(不同的会话历史)
- 并行分析:两个代理同时开始工作
- 交叉验证:一个代理的发现立即被另一个代理检查
- 无单代理盲点:如果一个代理遗漏了某些内容,另一个代理会捕捉到
设置指南
第一步:创建群集频道
创建一个专用的Discord频道(例如#swarming)用于多代理协作。
第二步:配置两个代理
两个代理都需要:
- - 在群集频道上设置requireMention: true
- 不同的mentionPatterns(每个代理自己的机器人ID)
- 各自的Discord机器人账户(独立的机器人令牌)
代理A配置(Mini 1 — openclaw.json):
json
{
channels: {
discord: {
accounts: {
default: {
guilds: {
YOURGUILDID: {
channels: {
SWARMINGCHANNELID: {
requireMention: true
}
}
}
}
}
}
}
}
}
代理B配置(相同模式,不同网关/Mini)。
第三步:循环防止规则
将以下内容添加到两个代理的SOUL.md文件中:
markdown
群集规则
- - 仅当你有新信息或反驳观点时才@提及另一个代理
- 不要回复简单的确认(同意、好观点、有道理)
- 在3次无新信息的交流后,总结发现并停止
- 始终以明确的行动项或结论结束
- 如果你同意另一个代理,简要说明并转向实施——不要为了辩论而辩论
第四步:多网关路由(关键)
如果两个代理运行在同一个网关(同一个Mini)上,你需要:
- - 为每个代理设置独立的Discord账户(独立的机器人令牌)
- 通过代理配置中的accountId将每个账户绑定到特定的代理ID
- 如果没有这个设置,两个代理都会收到每条消息,错误的代理可能会回复
如果代理运行在不同的网关(不同的Mini)上,这是自动完成的——每个网关只有自己的代理。
何时使用群集
适合群集的场景:
- - 复杂调试(配置问题、多层问题)
- 架构决策(两个视角优于一个)
- 研究综合(同一主题的不同角度)
- 代码审查(一个检查逻辑,另一个检查边界情况)
不值得群集的场景:
- - 简单任务(一个代理就足够了)
- 常规维护(使用单个更便宜的模型)
- 任何有明确已知流程的事情
成本考量
每次交流需要两次Opus调用而非一次。但是:
- - 问题解决速度快2-4倍
- 更少的错误方向(交叉验证及早发现错误)
- 净令牌使用量通常更低,因为避免了单个代理长时间的自旋
为了优化成本,你可以使用Opus + Sonnet进行群集,而非Opus + Opus。Sonnet代理负责验证,而Opus负责繁重的思考。
实际案例
两个Opus代理正在调试一个OpenClaw配置路由问题。代理A(Harrison)研究频道白名单配置。代理B(Prometheus)找到了根本原因——缺少账户绑定——并进行了修补。总时间:5分钟。单个代理预估时间:20分钟以上。
关键洞察:它们同时从不同角度攻击问题。Harrison查看频道配置层,而Prometheus查看账户绑定层。任何一个单独代理都无法如此快速地找到这两个问题。
包含文件
- - SKILL.md — 本文件(设置指南+模式)
- templates/SWARMINGRULES.md — 可复制粘贴的代理SOUL.md文件规则
- templates/CHANNELCONFIG.md — OpenClaw配置示例片段