fix: @mention 白名单过滤 + 队列上下文修复 + thread bypass 智能判断 - #232
Conversation
将 @mention 过滤从"没被拦住就放行"改为"必须有明确 passReason 才放行"。 原来 shouldRespond 返回 false 时静默 return 不留日志,导致无法诊断 群聊话题内 bot 未被 @mention 却主动响应的问题。 - 新增 resolveMentionGate() 统一所有 @mention 决策逻辑 - 新增 getRespondReason() 替代 shouldRespond 返回放行原因 - 每条消息的过滤决策都留 info 日志 (passReason 或 blocked) - 新增 29 个 mention-gate 测试 + 12 个 getRespondReason 测试 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
根因:task queue 的 .finally() 回调继承前一个任务的 AsyncLocalStorage 上下文。当 pm bot 的消息在 dev bot 任务完成后出队执行时,feishuClient 会用 dev 的凭证发送响应,导致"@土豆儿但张全栈回复"。 修复:在 QueueTask 中保存 accountId,processQueue 执行时用 runWithAccountId 恢复正确的上下文。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- queue.test.ts: 新增 3 个 accountId 存储/传递测试 - queue-context.test.ts: 新增 6 个 AsyncLocalStorage 上下文测试 - 复现 bug:.finally() 继承外层上下文导致 pm 任务用 dev 凭证 - 验证 fix:als.run() 包裹后每个任务获得正确上下文 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
审批/管道/记忆卡片按钮的回调 handleCardAction 此前未包裹 runWithAccountId,导致 feishuClient 走 defaultClient。 与 message handler 和 bot-added handler 对齐。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- 话题内只有创建者和 bot 两人时直接放行,不走 Qwen - 多人话题时,拉 fetchRecentMessages 构建对话上下文喂给 Qwen, 让 Qwen 看清发言者身份判断消息在跟谁说话(之前只看一条文本) - 新增 formatThreadContext 将话题消息格式化为 [人名]: 内容 - 结果卡片底部加上 hostname:pid 标识实例来源 - 更新 mention-gate 测试覆盖双人/多人场景 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
13d5076 to
aea9e10
Compare
|
Claude finished @lishuceo's task in 5m 29s —— View job Code Review SummaryVerdict: Tasks
What's Good ✅
Issues Found 🟡
其他观察(不阻塞)
整体评价变更聚焦清晰:白名单化 + 上下文修复 + 智能分流三件事都在同一主题下,提交粒度合理(5 个 commits 各自独立可读),测试质量很高(特别是 |
多 bot 场景下,pm-bot 的回复不再被误标为当前 bot 名字。 用 accountManager.getBotOpenId 区分 self vs 其他 bot。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 1m 43s —— View job Code Review SummaryVerdict: ✅ Approved — 1 previous issue fixed Tasks
Previous Issue Resolution🟡 → ✅
新增检查(无新问题)
整体评价变更聚焦清晰,先前 reviewer 的 inline 反馈已精准修复,方案与建议一致并复用了已有的 |
从 accountManager 和 chatBotRegistry 查找 bot 名字, Qwen 看到的对话记录从 [其他bot] 变为 [土豆儿(bot)]。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 1m 25s —— View job Code Review SummaryVerdict: ✅ Approved — latest commit refines an already-approved change Tasks
What Changed Since Last ReviewOnly 1 new commit ( const botNameMap = new Map<string, string>();
for (const acc of accountManager.allAccounts()) {
if (acc.botOpenId) botNameMap.set(acc.botOpenId, acc.botName);
}
// ...
name = m.senderId === selfBotOpenId
? `${botName}(bot)`
: `${botNameMap.get(m.senderId)
?? chatBotRegistry.getBots(chatId).find(b => b.openId === m.senderId)?.name
?? '其他bot'}(bot)`;Now Qwen sees Verification
Minor Observations (non-blocking)
Overall变更是上轮 reviewer 反馈的一个补全:从"区分 self/other"进一步到"显示 other bot 的具体名字"。改动小而聚焦,类型安全,行为正确,与既有的 |

变更概述
.finally()回调继承前一个任务的 AsyncLocalStorage 上下文导致 bot 身份错乱(@土豆儿但张全栈回复)测试计划
🤖 Generated with Claude Code