fix(extended_chat): keep real tool errors and recover chat lookup by id - #1134
Open
3316891527 wants to merge 2 commits into
Open
3316891527 wants to merge 2 commits into
3316891527 wants to merge 2 commits into
Conversation
Stop treating send timeouts as success, keep native error text, require one bound role per chat, and fail if chat service cannot start.
If find_chat only trusts the in-memory chat list, a valid UUID can still fail with Chat not found. Fall back to DAO-backed existence checks and accept current as the active window.
CATMIAOZHI
self-requested a review
September 25, 2026 07:19
CATMIAOZHI
approved these changes
Sep 25, 2026
CATMIAOZHI
left a comment
Collaborator
There was a problem hiding this comment.
审计结论:✅ 批准合并
改动(3 文件,+345/−216):修复 extended_chat 插件的错误语义与会话查找——超时不再伪装成功、保留原始工具错误、角色卡查找不再吞异常、startService 失败向上传播、传入已有 chat_id 时校验一角色一会话、find_chat 支持按 id / current 查找并带回退恢复。
通过的检查:
- 目标分支为 dev ✓
Promise.race超时写成功已移除,改为等待宿主原生timeout_ms;语义变更(超时从成功变为失败)在 PR 描述中明确披露- 工具失败不再统一包成「读取对话消息失败」,原始错误文案保留,符合"keep real tool errors"
- 角色卡查找移除空
catch,精确匹配→大小写不敏感匹配,listCharacterCards异常向上传播 startService失败不再忽略,会阻断发信(符合描述)findChatRobust回退链完整:宿主findChat→listChats(200)→agentStatus存在性确认;current 别名只递归一层,无无限递归;非"找不到"类错误直接 rethrow,不吞异常- 三文件(
examples/extended_chat.ts、examples/extended_chat.js、app/src/main/assets/packages/extended_chat.js)内容同步,已核验 read_messages_range描述修正(行号含库内 summary 等隐藏行),文档准确- PR 描述与 diff 一致
问题:
- [P2]
recoveredByIdOnly路径跳过了一角色一会话校验:chat_with_agent传入已有 chat_id 时,若会话仅通过agentStatus恢复(synthetic chat,无绑定信息),if (!existing.recoveredByIdOnly)直接跳过绑定角色校验。这与 PR 描述中"传入已有 chat_id 时要求该会话已绑定角色,并按角色 id 或名称校验一角色一会话"不一致;且findListedChatById的listChats({ limit: 200 })是固定上限,会话超过 200 个的用户可能误入该路径。建议:文档注明该例外,或对该路径尝试分页获取绑定信息。 - [question] 宿主
sendMessage的原生timeout_ms超时后是 reject 还是 resolve?若宿主超时后 resolve(而非 reject),超时仍会被当成成功返回,本 PR「超时不再当成功」的核心目标就没达成。请确认宿主行为。 - [P3]
'.'被收进CURRENT_CHAT_ALIASES:标题恰为.的会话将永远查不到(被解析为当前会话)。 - [P3]
cardResult.cards对 null/undefined 无保护(cardResult?.cards ?? []更稳妥);旧代码同理,顺手可修。 - [P3]
isMissingChatQueryError依赖英文错误文案匹配;若宿主错误信息被本地化,回退逻辑不会触发。
由 水晴喵的muse 审计
| if (!existing?.id) { | ||
| throw new Error(`Chat not found: ${chatId}`); | ||
| } | ||
| if (!existing.recoveredByIdOnly) { |
Collaborator
There was a problem hiding this comment.
[P2] recoveredByIdOnly 的 synthetic chat 会跳过一角色一会话校验(无绑定信息可查),与 PR 描述声称的「传入已有 chat_id 时要求绑定角色」不一致;且 findListedChatById 的 limit: 200 可能让会话多的用户误入该路径。建议文档注明例外,或尝试分页获取绑定信息。
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.
变更说明 / Description
背景与动机 / Context and motivation
extended_chat对宿主聊天 API 的错误处理和会话查找不够准确:超时可能被当成成功,失败文案被统一改写,按 id 查找时可能错过实际存在的会话。改动范围 / Changes
chat_with_agent不再用Promise.race把发送超时写成成功,只等待原生timeout_ms。catch吞掉;按名称精确匹配,否则大小写不敏感匹配。startService失败会让chat_with_agent失败,不再忽略。chat_id时要求该会话已绑定角色,并按角色 id 或名称校验一角色一会话。read_messages_range的工具描述标明行号包含库内 summary 等隐藏行。find_chat/ 按标题解析会话 /chat_with_agent校验已有会话时:先走宿主findChat;query 为对话 id 仍找不到则用list_chats和agent_status再确认;支持current解析为当前会话。不同步修改宿主
findChat、工作流或其它插件。兼容性与风险 / Compatibility and risks
chat_with_agent超时从成功变为失败。chat_with_agent。startService失败会阻断发信。关联 Issue / Related issue
N/A。内置
extended_chat插件修复。验证方式 / Verification
证据 / Evidence
2 commits, 3 files (
examples/extended_chat.ts,examples/extended_chat.js,app/src/main/assets/packages/extended_chat.js).