Bug: agent loop crashes after bash tool call — 'Cannot read properties of undefined (reading \'prepare\')' kills session (3 consecutive turns) #4601
Replies: 5 comments
|
Same error string as #4529, which got a confirmed root cause yesterday — so start there. Confirmed mechanism (from #4529): Check (macOS): One detail in your report cuts against the static-duplicate theory, and it is the discriminating question: your
For maintainers, two hardening notes (carried over from #4529): Separately: if that session now rejects every request with 400 |
后续复现与根因确认(web profile / GUI 环境)在 #4601 原帖的 web profile / GUI 场景下,我们继续排查并拿到了完整证据链。整体证实了 #4529 的静态符号机制,但具体触发路径与"第二份 环境快照(仅与本 bug 相关)
一、会话级证据(来自完整
|
| turn | tool/call | tool/result | 结果 |
|---|---|---|---|
| 1–13 | 全部=result 数 | 全部配对 | ✅ 正常 |
| 14/15/16 | 1 | 0 | ❌ prepare 崩溃 |
| 18–23 | 各 1 | 0 | ❌ prepare 崩溃(6 连) |
| 24 → 用户重启/resume 后 | 全部配对 | 全部配对 | ✅ 恢复 |
铁证链:
- turn 1–13 完全正常(每个 tool/call 都有对应 tool/result)
- turn 14 起每次
tool/call序列为tool/call → step/end → turn/end(reason.error "Cannot read properties of undefined (reading 'prepare')", code UNKNOWN),tool/result从未写出,共 10 个连续 turn 崩溃(比原帖"3 个"更严重) - 崩溃不影响纯文本回复(无 tool 的 turn 正常
turn/end completed)—— 与 --profile headless crashes on any tool call: "Cannot read properties of undefined (reading 'prepare')" (0.1.1-rc.2) #4529 作者观察一致:模型/provider 路径健康,故障在 tool 分发层 - 同一会话内用户重启后 resume 即恢复(
reason:"resume")—— 对应 --profile headless crashes on any tool call: "Cannot read properties of undefined (reading 'prepare')" (0.1.1-rc.2) #4529 维护者给出的判别问题 #2"是否在 resume/relaunch 进程里":是。崩溃在进程生命周期内 mid-session 出现,与静态启动重复略有差异
二、复现(可稳定复现)
- 崩溃 turn 18 的 bash 命令恰好是安装/首次触碰某第三方视觉插件的
mkdir .../.dsh-vision-toolkit/tmp/...—— 即在崩溃瞬间用户正在触碰该插件,随后 turn 19/20 读该插件相关路径 - 禁用该第三方视觉插件(
disabled: true)并重启dsh web后,新会话工具全部恢复正常(bash/read/glob 均返回结果) - 该插件 enable/disable 是"能否稳定再现"的开关,可复现
三、本地包层证据(对照 #4529 的"第二份 dsh-tools")
- 全盘扫描
node_modules/@deepseek-ai/dsh-tools:仅 1 份(在全局 dsh CLI 内),没有 profile 内副本 - 但 profile
node_modules/@deepseek-ai/下存在 3 个额外核心包(dsh-credentials、dsh-home-paths、dsh-typert-protocol),其版本为0.1.0-rc.8,晚于全局 CLI 的0.1.1-rc.2(版本漂移) - 已确认
packages/core/tools中TOOL_RUNTIME_SCHEDULER = Symbol("@deepseek-ai/dsh-tools.scheduler")是普通Symbol()而非Symbol.for()(本机 0.1.1-rc.2 存在)
结论修正:本机并非"存在第二份 dsh-tools",而是第三方插件通过其 peerDependencies 在 profile 内拉进了多份版本漂移的核心 @deepseek-ai/dsh-* 包(0.1.0-rc.8 ≠ 全局 0.1.1-rc.2),破坏了 TOOL_RUNTIME_SCHEDULER 的 Symbol 一致性,导致 registry[TOOL_RUNTIME_SCHEDULER] 取到 undefined,.prepare 崩。禁用该第三方插件即移除了注入源,Symbol 恢复一致,工具恢复。根因与 #4529 归属同一机制(Symbol() 非 Symbol.for() 对重复加载不健壮),但触发载体从"静态二次安装"扩展到了"第三方插件 peer 依赖在 profile 内的版本漂移"。
四、对维护者的两点建议(呼应 #4529)
Symbol.for('@deepseek-ai/dsh-tools.scheduler')可消除重复/漂移副本的差异(已在 --profile headless crashes on any tool call: "Cannot read properties of undefined (reading 'prepare')" (0.1.1-rc.2) #4529 提过,再次附议)- 建议为
registry[TOOL_RUNTIME_SCHEDULER]命中undefined时输出可行动诊断(命名可能的本机重复/漂移来源,而非裸UNKNOWNTypeError)—— 本次排查花费大量人时才找到根因,因为错误被统一抹平成UNKNOWN,且崩溃发生在 web 会话内、不落 stderr。
附:诊断配方(便于维护者/用户复现定位)
# 1. 服务层 vs 客户端层分离
curl -s -o /dev/null -w "HTTP %{http_code}\n" http://127.0.0.1:3080/ # 服务一直 200
# 2. 崩溃在 web 会话 log(不落 stderr):解析 session.jsonl 找 turn/end error
# 3. 全盘找 dsh-tools 副本 + profile 核心包版本漂移
find ~/.dsh ~/.npm-global -type d -name dsh-tools 2>/dev/null
ls ~/.dsh/profiles/web/node_modules/@deepseek-ai/ # 版本 vs 全局 dsh,找漂移
# 4. 二分 disable 第三方插件(本机罪魁为该视觉插件)|
补充复现诊断附件(gist): 📎 https://gist.github.com/SilenZerOrz/71fd96f3d22a26490c8e2d84522f35fc 内含:
复现命令: python3 turn_summary.py session.jsonl直接复现本报告的 J 型故障(turn 1–13 全部 tool 有 result → turn 14–23 每次 完整原始 |
|
The event skeleton adds an important discriminator: this is not enough evidence to label the incident a static duplicate present at process boot. The join that matters is tool history + Host process generation.
One attribution detail is also worth tightening: The unpaired I incorporated the new evidence into a revised source-backed failure router and recovery contract: https://sandbaseai.github.io/deepseek-harness-handbook/duplicate-core-runtime.html Disclosure: I maintain the independent community handbook linked above. |
|
感谢两轮审阅(tancheng33 / denial123789)。按"需要找到 dsh-tools 的第二条求值边"的方向做了针对性验证,结果如下。 事实:profile 内存在第二份
|
Uh oh!
There was an error while loading. Please reload this page.
"## \ud83d\udc1b Bug Report\n\nThe agent loop crashes mid-turn with a raw Node.js runtime error, terminating the turn as
errorwith codeUNKNOWN. The turn logsstep/endimmediately after atool/callis issued and never produces atool/result\u2014 the engine dies instead of letting the tool complete.\n\n### Error\n\nCaptured from the session event log (turn/endreason):\n\n\nCannot read properties of undefined (reading 'prepare')\ncode: UNKNOWN\n\n\nIt happened three turns in a row (turn 14, 15, 16), so it's consistently reproducible in this session rather than a one-off glitch \u2014 it effectively killed the whole session.\n\n### Steps to reproduce\n\n1. Run dsh in a session (web/headless profile).\n2. Have the agent issue abashtool call (in our case a network-connectivity diagnostic usingcurl).\n3. Observed sequence in the session log:\n -tool/call(bash) \u2014 emitted\n -step/end\u2014 emitted immediately (notool/resultwas ever written)\n -turn/endwithreason: {kind: \"error\", error: {message: \"Cannot read properties of undefined (reading 'prepare')\", code: \"UNKNOWN\"}}\n\nThe stack originates inside the harness when it tries topreparesomething (toolpreparepath /prepareProfile) and dereferences a property onundefined.\n\n### Expected vs Actual\n\n- Expected: thebashtool runs, returns atool/result, and the loop continues. A runtime error like this should not abort the session.\n- Actual: the turn aborts withturn/end(error)and notool/resultis produced; recurs on 3 consecutive turns.\n\n### Environment\n\n- dsh version:0.1.0-rc.8(npm@deepseek-ai/dsh; latest on npm is0.1.1-rc.2)\n- OS: macOS (Apple Silicon Mac Mini)\n- Node: v22.x\n- Session policy:workspace-write, approvalask\n- Model used by session: DeepSeek-V4-Flash\n\n### Additional context\n\n- A related (distinct) symptom in the same session: theweb_searchtool returnedError: Authentication Fails, Your api key: ****0700 is invalid(codeWEB_PROVIDER_ERROR) \u2014 the configured search tool key was invalid. The crash happened while the agent was falling back tocurlnetwork checks.\n- The crash triggers right after atool/callforbash; likely area to inspect is the toolprepare/result-handling path.\n\nFull session event log (session.jsonl) showing the threeturn/enderror events is available on request.\n"All reactions