Repository navigation
ToolRuntime scheduler lookup silently returns undefined when multiple physical copies of @deepseek-ai/dsh-tools exist in one process (Symbol-key mismatch)
#572
Replies: 3 comments
|
This lands the "registry-based key" fix you suggested in point 2 β a one-line |
|
Same key mismatch also arrives with no third-party package at all: on a pristine checkout ( |
|
Hitting the same crash on 0.1.6-alpha.2, Windows, launched from source with: node --import tsx/esm apps/cli/src/bin.ts web The model request itself succeeds. The first tool call (glob and pwsh together) writes the tool/call, then the turn dies with: Cannot read properties of undefined (reading 'prepare') After that the session is stuck. Every later user message fails locally, before it ever reaches the model: DeepSeek Messages tool calls need immediate results turn/end is already recorded as an error, so interruptedTurnClosers will not fill in the missing tool/result. I had to abandon the session. This does not look like the extra copy under the profile. ~/.dsh/profiles/web/node_modules only has dsh-context and zod. There is no second @deepseek-ai/dsh-tools hoisted there. What I can reproduce is loading src and lib/index.js in the same process: both symbols print as Symbol(@deepseek-ai/dsh-tools.scheduler), and they are not ===. I have a local fix on fix/tool-scheduler-shared-symbol. It is not on my fork yet (push to GitHub keeps dying on port 443). Two changes:
Happy to open a PR once the push goes through. |
Uh oh!
There was an error while loading. Please reload this page.
ToolRuntime scheduler lookup silently returns
undefinedwhen multiple physical copies of@deepseek-ai/dsh-toolsexist in one process (Symbol-key mismatch)Summary
In the web profile, tool dispatch can crash the engine process with:
at
dsh-agent-loop/lib/index.js:193:The lookup yields
undefinedwith no diagnostic β a bare TypeError. The crash is intermittent in the sense that it can happen on the very first tool call of a process or at an arbitrary mid-session call, and it is not tool-specific (read,pwsh,skilland nocturne tools all triggered it).Root cause
TOOL_RUNTIME_SCHEDULERis a Symbol key exported by@deepseek-ai/dsh-tools(lib/index.js:2409, public export list at:3570) and attached to theToolRuntimeservice instance as a class field (:2557; the instance is thetoolsservice itself,super(ctx, "tools")at:2585). Symbols are module-unique: if one process loads more than one physical copy ofdsh-tools, each copy has its own Symbol, and a lookup performed with one copy's Symbol against an instance created by another copy returnsundefined.dsh-agent-loopimports the key from@deepseek-ai/dsh-tools(lib/index.js:10) β its copy of the Symbol is whichever physical copy its own module graph resolved. (All references verified against the installed engine source.)In our setup the process contained three physical copies of
dsh-tools@0.1.0-rc.6:node_modules/@deepseek-ai/dsh-tools(npm install)profiles/web/node_modules/@deepseek-ai/dsh-tools(pnpm,nodeLinker: hoisted)profiles/node_modules/@deepseek-ai/dsh-tools(pnpm hoisted layer)A
pnpm overridesentry forcingdsh-tools@0.1.0-rc.6did not fix it β overrides only pin versions; they do not remove physical duplicates.Verification of the diagnosis
After replacing the four resolved copies (
cordis,cosmokit,dsh-tools,schemastery) underprofiles/web/node_modules/@deepseek-ai/with junctions pointing at the engine's copies, the crash disappeared: 4 fresh sessions across 2 restarts, exercisingread,pwsh,glob,skilland same-message parallel tool calls β all completed withturn/end completed, zeropreparecrashes, no dangling tool calls.What would help
ctx.tools[TOOL_RUNTIME_SCHEDULER]isundefined, emit a diagnostic error (e.g. "ToolRuntime instance was created by a different physical copy of@deepseek-ai/dsh-tools; multiple copies detected β unify your install") instead of a bare TypeError withcode: UNKNOWN.package.json+pnpm-workspace.yamlwithnodeLinker: hoisted, which materializes real copies rather than symlinks. A documented, supported install layout for profiles (e.g.nodeLinker: isolatedwith a shared store, or a required dedupe step) would prevent this whole class of failures.Evidence
68d5a535,4d74d165,d73793d6,e371ca13,41b9c9d7,8ab28246.8a3183d8,35035f2c,09d7f2f5,396c8d4e.~/.dsh/sessions/) available on request.Workaround
Unify the module instances: point the profile's
@deepseek-ai/*resolution layer at the engine'snode_modulescopies (junctions work on Windows), or install everything from a single store. Avoid re-runningpnpm installwithnodeLinker: hoisted, which recreates the real copies.Related
This crash is what triggered the session-poisoning defect reported in the companion post β Session permanently poisoned after a tool-dispatch crash: dangling
tool_callsmake every later request fail with 400 "insufficient tool messages". Note that the poisoning defect applies to any dispatch failure and stands on its own.All reactions