Tool layer fails with "Cannot read properties of undefined (reading 'prepare')" after installing third-party plugins #1486
Replies: 3 comments
|
Excellent root-cause analysis — the dual-module-instance + per-module This is the third entry in a pattern I've been collecting around
Same root theme: A data point that may help: in my web profile, the same duplicated On the fixes: Thanks for the instrumentation — this makes the class of failure much easier to reason about. |
|
Thanks for the field confirmation — this is the #1486 mechanism live, and "restart doesn't fix it" matches: the two module instances coexist in the same process regardless of restart, so only removing the duplicate (or the plugin that pulls it in) recovers the tool layer. Quick fixes, fastest first:
If you want to confirm the condition before touching anything: our offline checker (shared in #1534) has a P5 check for exactly this — |

Uh oh!
There was an error while loading. Please reload this page.
Tool layer fails with "Cannot read properties of undefined (reading 'prepare')" after installing third-party plugins
Environment: Windows 11,
@deepseek-ai/dsh@0.1.0-rc.6(latest), web profileSeverity: High for users who install third-party plugins into a profile
Summary
After installing third-party plugins into the web profile (plugins that depend on
@deepseek-ai/dsh-tools, e.g. dsh-undo, dsh-restart, dsh-mneme, dsh-balance-meter),every model tool call fails with:
The UI shows
本轮运行失败(this round failed) for the tool, and the agent loopbreaks. The headless profile works fine.
Repro steps
dsh plugin --profile web add <any-plugin-that-depends-on-@deepseek-ai/dsh-tools>dsh webpwsh/Get-Date)Cannot read properties of undefined (reading 'prepare')Root cause
dsh plugin addforwards to pnpm, and pnpm hoists the plugin's transitive@deepseek-ai/*dependencies into the profile's own node_modules:Both copies are loaded into the same process, so there are two module
instances of
dsh-tools. Each instance has its own localSymbol:Symbol('x') !== Symbol('x')across module instances. Instrumentation confirmed:ToolRuntimeinstance behindctx.toolsis constructed by copy A(profile copy) — its
[TOOL_RUNTIME_SCHEDULER]property is keyed by copy A's symbol.dsh-agent-loopimportsTOOL_RUNTIME_SCHEDULERfrom copy B (framework copy),so
ctx.tools[symbolB]isundefined, andctx.tools[TOOL_RUNTIME_SCHEDULER].prepare(exec)throws at runtime.
cosmokit,dsh-llm,dsh-settings,schemastery— all duplicated.Suggested fixes (any one would help)
Symbol.for('@deepseek-ai/dsh-tools.scheduler')(global symbol registry) indsh-toolsso the key survives duplicate module instances.dsh-agent-loopresilient (fall back whenctx.tools[TOOL_RUNTIME_SCHEDULER]is undefined).dsh pluginflow, dedupe@deepseek-ai/*packages that alreadyexist in the framework install (e.g. prefer the framework copy, or symlink).
Workaround (verified)
Replace version-identical duplicated
@deepseek-ai/*packages inprofiles/<profile>/node_modules/@deepseek-ai/with directory junctions pointingat the framework copy — Node.js dedupes by realpath, restoring a single module
instance. Note that every subsequent
dsh plugin add/remove(pnpm install)recreates the real copies, so the dedupe must be re-applied after each install.
All reactions