Skip to content

[Bug]: mnemon_subagent_result 的工具实参系统性缺少最外层闭合括号,delegated 子任务约 12% 失败 #636

Closed

Description

@ryx2632927096-star

提交前查重 / Duplicate check

  • 我已搜索 open/closed Issue,确认没有重复。 / I searched open and closed issues and found no duplicate.

查重记录(5 组关键词,全部执行,含 0 命中的):

关键词 total 命中是否相关
subagent_result JSON 0 —
Expected property value 3 否(#493 只读属性、#147 token 用量字段、#125 UI 配色)
tool arguments parse 0 —
invalid JSON result 7 否(#548 emoji 代理对、#55 AI 元数据、#454 分数分档等)
closing brace 0 —

另已核对已合并 PR:#615(idle review 默认 4096 预算)、#570/#571(skill draft 16k 预算)。两者修的是 memory subagent stopped with max-tokens,与本 issue 的 Expected ',' or '}' 是不同失败形态,见下方「与本仓库既有边界的对齐说明」。

涉及区域 / Affected area

子 Agent 或 Agent 工作流 / Subagent or Agent workflow

Issue 类型 / Issue type

Bug 报告 / Bug report

摘要 / Summary

mnemon_subagent_result 的工具实参 JSON 被模型系统性少写一个最外层闭合括号,导致 [dsh-mnemon:delegated skill] 子任务约 12% 失败。报错恒为:

Tool call "mnemon_subagent_result": Expected ',' or '}' after property value in JSON at position N

预期结果 / Expected outcome

delegated 子任务完成工作后,调用 mnemon_subagent_result 回传的结构化结果应能被正常解析并记入,子任务以 completed 结束。可验证结果:[dsh-mnemon:delegated *] 子任务成功率为 100%,错误记录中不再出现 Expected ',' or '}' after property value。

详情或复现步骤 / Details or reproduction steps

  1. 配置 / Configure:skills.evolution: true、skills.autoAdopt: true、idleSeconds: 20、cooldownSeconds: 150。
  2. 正常使用 DSH 会话并保持空闲,让 mnemon 触发 skill 进化派发。
  3. mnemon 派发 [dsh-mnemon:delegated skill] 子 agent,子 agent 完成后调用 mnemon_subagent_result。
  4. 观察到 / Observe:约每 8 次派发里有 1 次在回传这一步失败,子 agent 报 JSON 解析错误并终止。

实测统计:同一时段内 [dsh-mnemon:delegated *] 子任务成功 101 次、失败 16 次,失败率 12.2%。

环境信息 / Environment

  • DSH 版本 / DSH version: 0.2.2-rc.1
  • dsh-mnemon 版本或 commit / dsh-mnemon version or commit: 0.5.43(npm 安装;上游最新为 0.5.45)
  • Mnemon 版本 / Mnemon version: 随插件,0.5.43
  • Node.js / pnpm: v24.22.2
  • 操作系统或浏览器 / OS or browser: Windows 11(10.0.26200),DSH 桌面版
  • Provider 或相关配置(已脱敏)/ Provider or related configuration (redacted):
    • skills.draftMaxTokens: 32768,skills.draftRetryMaxTokens: 65536
    • subagentProviderNames 影响派发出口;本报告已剔除 provider 名称、账号与任何路径中的用户名
    • 失效操作类型为 skill

Bug 证据 / Bug evidence

对 16 次失败的工具实参逐条做结构统计,规律完全一致:

指标 16 条实测
{ 与 } 的计数 恒为「左比右多 1」
[ 与 ] 的计数 全部配平
字符串引号 全部成对闭合(无一条断在半句话中间)
实参末尾 3 字符 恒为 "}]
报错 position 恒等于实参总字符数

逐条指标(chars 为收到的实参字符数,pos 为报错位置,curl 为 {/},sq 为 [/]):

 1. 2026-11-14 02:05:42  chars=2419  pos=2419  curl=5/4  sq=3/3
 2. 2026-11-14 02:25:27  chars=2148  pos=2148  curl=3/2  sq=1/1
 3. 2026-11-14 02:25:30  chars=936   pos=936   curl=2/1  sq=1/1
 4. 2026-11-14 02:25:39  chars=1152  pos=1152  curl=2/1  sq=1/1
 5. 2026-11-14 02:26:08  chars=1698  pos=1698  curl=2/1  sq=1/1
 6. 2026-11-14 02:27:29  chars=936   pos=936   curl=6/5  sq=1/1
 7. 2026-11-14 02:27:37  chars=2058  pos=2058  curl=3/2  sq=1/1
 8. 2026-11-14 02:27:50  chars=647   pos=647   curl=3/2  sq=1/1
 9. 2026-11-14 02:37:01  chars=1379  pos=1379  curl=2/1  sq=1/1
10. 2026-11-14 02:37:17  chars=1468  pos=1468  curl=2/1  sq=1/1
11. 2026-11-14 02:37:24  chars=3657  pos=3657  curl=2/1  sq=1/1
12. 2026-11-14 02:37:58  chars=4096  pos=4096  curl=7/6  sq=1/1
13. 2026-11-14 04:51:01  chars=4110  pos=4110  curl=2/1  sq=3/3
14. 2026-11-14 05:00:42  chars=3181  pos=3181  curl=10/9 sq=2/2
15. 2026-11-14 05:05:44  chars=2623  pos=2623  curl=3/2  sq=2/2
16. 2026-11-14 05:06:04  chars=2174  pos=2174  curl=6/5  sq=2/2

各条实参末尾 6 字符(已替换业务关键词为占位符):

 1. ...`/healthz`;并确认无遗留临时探针。"]}
 2. ...-package.ps1` 布景,代码不动你的项目文件。"}
 3. ...口类型、工作目录、提示符已就绪、登录动作完全交给用户。"]}
 4. ... 均报错),如实报告失败与报错原文,不静默重试第三次。"]}
 5. ....exe 可用,并用截图核对了标题与提示文案显示正常。)"}
 6. ...面自身 datePublished”,不拼凑 URL。"]}
 7. ...而是那天 CI 里的旧凭据突然失效、发版卡死。"}
 8. ...么」三段整理成中文清单,附发布者与仅安装者的分流结论。"]}
 9. ...凭据、浏览器密码库,也未索要恢复码或 OTP。"]}
10. ..._subagent_result 回传步骤与最终答复。"]}
11. ...文的迁移说明——迁移步骤本次没抓正文,我不凭印象给命令。"}
12. ...打印凭据、也不需要你把恢复码或 OTP 贴给我。"}
13. ...isten`、无新页面弹出(我不擅自重启宿主中断会话)。"}
14. ...emon_subagent_result 一次性提交。"]}
15. ...(原字段在 0.5.x 已改为单条 JSON)。"]}
16. ...(该键在 0.5.x 已被合并处理)。"]}

这不是 max-tokens 截断,两条实证:

  1. 最小失败样本仅 647 字符(约 300-500 token),远低于 skills.draftMaxTokens: 32768。
  2. 若被 max-tokens 硬切,字符串应可能断在半句、[ 也可能不等、末尾停在文本中间。实测 16 条字符串全部闭合、[ 全部配平、文本语义完整,只缺最外层 }。

冒烟测试 / Smoke test

  • 测试环境 / Test environment: 同上,DSH 0.2.2-rc.1 + dsh-mnemon 0.5.43,Windows 11。
  • 执行命令或操作 / Commands or actions: 持续使用会话并保持空闲,由 mnemon 自动派发 [dsh-mnemon:delegated skill] 子 agent;从事件通知历史中提取每次失败的完整工具实参。
  • 实际结果 / Observed result: 101 成功 / 16 失败;16 条失败的实参结构统计 100% 一致({ 比 } 多 1、[ 配平、引号成对、末尾 "}]、pos 等于长度)。
  • 对照版本或配置 / Control version or configuration: 同一 DSH 版本、同一 provider 配置下,另外 101 次同样工具、同样操作类型的调用成功,排除网络、provider 与宿主解析因素。

引用代码 / Code references

本地安装版 0.5.43 中相关位置(lib/index.js 为构建产物,此处仅用于定位对应源码):

  • RESULT_TOOL_INPUT_SCHEMA:result 定义为 { type: "object", additionalProperties: true },即自由对象,无字段约束。
  • completion protocol 仅以 JSON.stringify(outputSchema) 形式附加 schema,未见「必须输出可被 JSON.parse 接受的完整 JSON」之类的强化约束或正例。
  • perOpMaxTokens 中 operation === "skill" 分支取 skillMaxTokens ?? 16384,与本 issue 无直接关系(失败样本远未触及该预算)。

补丁草案 / Patch proposal

非必需,仅列两个方向供参考:

  1. 提示词层:在 completion protocol 中显式约束 JSON 闭合,给出最小正确样例,并明确「末尾必须有与首个 { 配对的 }」。
  2. 解析层容错:当实参解析失败且满足「仅缺尾部闭合括号」这一已知形态时,尝试补全后再解析,并记录 warn 日志。可立即把该形态的失败率降到接近 0,且不影响真正非法的输入。

补充信息 / Additional context

  • 无记忆数据丢失:相关 memory 已写入 Mnemon 存储,失败的只是回传确认这一步;实际损失为每次白烧一个子 agent 的 token 预算。
  • 该问题在 skills.evolution: true 下持续发生,本机两小时内 16 次。
  • 已排除:网络、provider 侧、输出预算上限、DSH 宿主解析(实参确实是非法 JSON,宿主报错正确)。
  • 16 条实参的完整原文可随时按要求补充提供(含业务内容,如需我会先脱敏)。

与本仓库既有边界的对齐说明 / Alignment with existing scope

按 CONTRIBUTING 的 Issue 规则,本报告使用双语 Bug 表单段落结构,并在提交前搜索了 open/closed Issue。

特别说明,本 issue 不是以下已修复问题的重复:

  • #615 fix(review): give idle review a comfortable default output budget —— 处理 idleReview.maxTokens 默认 4096 导致 review 撞预算,错误为 memory subagent stopped with max-tokens。
  • #570 / #571 fix(skills): configure draft budgets and retry truncated generation —— 处理 skill draft 撞 16k 预算,同为 max-tokens 形态。

上述两者的失败特征是预算耗尽;本 issue 的失败特征是实参缺少一个结构字符,且最短样本仅 647 字符,与预算无关。

本报告不涉及持久化格式、RPC 权限、凭据或安全边界变更,仅描述一次子 agent 回传通道的输入合法性问题。

Activity

  1. github-actions commented on Nov 13, 2026

    @github-actions

    此 Issue 保持打开。为便于排查,请补充以下基础信息:
    The issue remains open. Please add the following basic information to help triage:

    • 缺少或为空的必填部分 / Missing or empty required sections: 提交前查重 / Duplicate check, 涉及区域 / Affected area, Issue 类型 / Issue type, 摘要 / Summary, 预期结果 / Expected outcome, 详情或复现步骤 / Details or reproduction steps, 环境信息 / Environment

    在正文中补充即可,本提示会在编辑后更新。证据可以是普通文本、JSON 或其他代码块,也可以直接放在复现步骤中。
    Update the issue body and this reminder will refresh. Evidence may be plain text, JSON or other code blocks, including content in the reproduction steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions