fix: 父群图片 lazy loading + history-fork 实现合并 - #233
Merged
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>
多 bot 场景下,pm-bot 的回复不再被误标为当前 bot 名字。 用 accountManager.getBotOpenId 区分 self vs 其他 bot。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
从 accountManager 和 chatBotRegistry 查找 bot 名字, Qwen 看到的对话记录从 [其他bot] 变为 [土豆儿(bot)]。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
话题中分析简历时,buildChatHistoryContext / buildDirectTaskHistory 会从父群聊补充消息以填满 historyMaxCount,导致 downloadHistoryImages 把父群里其他人发的简历图片一并 base64 嵌入 prompt。 修复:downloadHistoryImages 接受 parentMsgCount,与 downloadHistoryFiles 行为对齐:父群图片只注入元数据提示(feishu_download_message_image 工具调用 hint),需要时由 LLM 主动加载。 之前文件已有 lazy loading(lines 1500-1507),但图片没有同等防护。
8 个用例覆盖: - parentMsgCount=0 时全部下载(向后兼容) - 父群图片仅生成 lazyHints 元数据,不下载 - 元数据格式包含 message_id / image_key / 工具名 - 父群-only / 话题-only / 无图片场景 - 话题图片下载失败时父群元数据仍正常输出 - 同一消息多张图片按来源分别处理 同时新增 _testDownloadHistoryImages export,与 _testDownloadHistoryFiles 风格对齐。
两个函数 95% 完全相同(fork 语义 + 增量去重 + 父群懒加载附件), 唯一差异是 direct 路径多打印一份诊断日志、错误日志的 label 不同。 抽出统一的 buildHistoryContext,通过 BuildHistoryOptions 控制 verboseLogging / errorLabel;buildChatHistoryContext 与 buildDirectTaskHistory 退化为薄包装,保留对外签名不变。 净减少 44 行,消除后续修这条 history-fork 路径时双地维护的负担。
Contributor
|
Claude finished @lishuceo's task in 3m 58s —— View job ✅ Approved — No critical issues foundReviewed the full diff against Verdict
What was checked1.
2.
3.
4. Queue accountId context isolation (
5.
6.
7.
Tests
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更概述
lazy-history-images.test.ts8 个回归用例覆盖 parentMsgCount 边界、下载失败、多图等场景buildChatHistoryContext与buildDirectTaskHistory95% 重复实现,抽出统一buildHistoryContext,净减少 44 行背景
土豆儿在话题中分析简历时,会把群聊历史里其他人发的简历图片一起下载分析,导致候选人信息混淆。原因是
downloadHistoryImages没有parentMsgCount保护,而downloadHistoryFiles已经有了。双层防御
feishu_download_message_image加载config/knowledge/recruitment.md追加"简历分析作用域规则",明确默认只分析话题内简历(不在本 PR,配置文件 deployment-specific)测试计划
🤖 Generated with Claude Code