⚠️ 重要:防止机器人无限循环错误配置会导致所有机器人陷入消息循环,频道报废。请务必按本文档配置。
现象:
- 机器人互相 @ 后,开始重复前一个机器人的回答
- 机器人"学会了@",主动 @ 其他机器人
- 使用
@everyone后,频道无限循环,所有机器人互相 @,频道报废
根本原因:三个配置叠加形成死循环
在 openclaw.json 的 channels.discord 中:
{
"channels": {
"discord": {
"allowBots": "mentions"
}
}
}三个选项对比:
| 值 | 行为 | 安全性 |
|---|---|---|
"mentions" |
只响应明确 @自己的 bot 消息 | ✅ 推荐 |
true |
响应所有 bot 消息(包括其他 bot 的回复) | ❌ 危险 - 会导致循环 |
false |
完全忽略所有 bot 消息 |
为什么 "mentions" 是最佳平衡:
- ✅ 司礼监 @ 兵部 → 兵部响应(协作正常)
- ✅ 兵部回复 → 不触发司礼监(没 @,不循环)
- ✅ 避免消息循环,保留多 bot 协作能力
在 messages.groupChat 中:
{
"messages": {
"groupChat": {
"mentionPatterns": []
}
}
}// ❌ 危险配置 - 会导致雪崩
{
"mentionPatterns": ["@everyone", "@here"]
}为什么 @everyone 是核弹:
- 用户发送
@everyone - 所有 10+ 个 bot 同时认为自己被提到
- 所有 bot 同时回复
- 每个 bot 的回复又触发其他 bot
- 5 轮后:10 × 3^5 = 2430 条消息,频道报废
在 channels.discord.guilds 中:
{
"channels": {
"discord": {
"guilds": {
"YOUR_SERVER_ID": {
"requireMention": true,
"ignoreOtherMentions": true
}
}
}
}
}作用:bot 只响应 @自己的消息,@别人的消息一律忽略。
{
"channels": {
"discord": {
"enabled": true,
"allowBots": "mentions",
"groupPolicy": "allowlist",
"guilds": {
"YOUR_SERVER_ID": {
"requireMention": true,
"ignoreOtherMentions": true,
"users": ["YOUR_USER_ID"]
}
}
}
},
"messages": {
"groupChat": {
"mentionPatterns": []
}
}
}在启动/更新后,运行以下检查:
# 1. 检查 allowBots 设置
grep -A 5 '"discord"' ~/.openclaw/openclaw.json | grep allowBots
# 预期输出: "allowBots": "mentions"
# 2. 检查 mentionPatterns
grep -A 3 'mentionPatterns' ~/.openclaw/openclaw.json
# 预期输出: "mentionPatterns": []
# 3. 检查是否有 @everyone 残留
grep -r '@everyone' ~/.openclaw/ ~/clawd/configs/
# 预期输出:无可能原因:allowBots 设成了 true
修复:
# 修改配置
openclaw config set channels.discord.allowBots '"mentions"' --json
# 重启 gateway
openclaw gateway restart立即措施:
- 手动暂停所有 bot(关闭 gateway)
- 清理 Discord 频道(删除循环消息)
- 按本文档修改配置
- 重启 gateway
预防:永远不要在配置中包含 @everyone 或 @here
可能原因:allowBots 设成了 false
修复:改为 "mentions" 而不是 false
不要用 @everyone,改用:
- 逐个 @需要的 bot
- 或者只 @司礼监,由司礼监内部分发
用户 → @司礼监 → 司礼监 @兵部 → 兵部执行
↓
兵部回复(不 @任何人)
↓
司礼监看到回复,继续调度
关键:bot 回复时不要 @其他 bot,让司礼监负责调度。
每次更新/修改配置后运行:
~/clawd/scripts/pre-update-check.sh最后提醒:配置完成后,先用小号/测试频道验证,确认无循环后再用于生产频道。