Repository navigation
Replies: 4 comments 2 replies
|
thanksοΌbut where is the path for dsh that's directly installed via npm? I don't see a packages/core/tools/src/index.ts at .dshοΌwindows user directoryοΌ |
|
Supporting this fix. Confirmed independently on the current |
|
Thanks for the diagnosis. I agree this looks like a module-instance duplication issue. Candidate one-line fix: diff -export const TOOL_RUNTIME_SCHEDULER: unique symbol = Symbol('@deepseek-ai/dsh-tools.scheduler');
+export const TOOL_RUNTIME_SCHEDULER = Symbol.for('@deepseek-ai/dsh-tools.scheduler');
If downstream types require unique symbol, the annotation may need to be adjusted because Symbol.for is typed as symbol rather than a fresh unique symbol. The important part is to use the global symbol registry. Why this helps: Symbol() creates a new symbol per module instance. Symbol.for() uses the global registry, so two physical copies of @deepseek-ai/dsh-tools resolve to the same key. A useful regression test would be: a third-party plugin declares @deepseek-ai/dsh-tools as dependencies instead of peerDependencies, then calls a tool. Before the fix, ctx.tools[TOOL_RUNTIME_SCHEDULER] is undefined; after the fix, it should resolve correctly. I have not tested this in a pnpm profile with a duplicated dependency yet. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ctx.tools[TOOL_RUNTIME_SCHEDULER]resolves toundefinedat tool dispatch becauseTOOL_RUNTIME_SCHEDULERis a module-localSymbol; when multiple physical copies of@deepseek-ai/dsh-toolsexist in one process, the agent-loop's key and the ToolRuntime field's key are unequal Symbols. A one-lineSymbol.forfix restores the lookup while preserving the author's intent.Repro / root cause / fix / verification
@deepseek-ai/dsh-toolsas a dependency (or a peerDependency whileautoInstallPeersis on), thendsh weband ask the agent to call any tool.Cannot read properties of undefined (reading 'prepare')atdsh-agent-loopstartCall; the turn ends withcode: UNKNOWN, leaving a danglingtool_callso later turns fail withINVALID_REQUEST.packages/core/tools/src/index.ts:466exportsSymbol('@deepseek-ai/dsh-tools.scheduler');dsh-agent-loopimports the same key from a different physical copy, so the two Symbols are not===.This is the dual package hazard β the Node.js-documented case where the same package loaded twice yields two module instances whose identity checks (
Symbol,instanceof,WeakMap) no longer match. Here the second instance comes from a duplicate physical copy rather than the usual ESM/CJS dual entry, andSymbol.foris the standard remedy.Symbol.foruses the global registry, so the key is identical across all module instances. It stays a Symbol, preserving the@internal"omitted from the generated named service API" intent.dsh webinstance now completes tool calls (turn/end completed,tool/resultpresent) on 0.1.0-rc.6.leether/deepseek-harnessβfix/tool-runtime-scheduler-symbolβ a clean single-commit fork branch (the fork'smastertracks upstream).All reactions