[Bug] Web mode tool execution fails: Cannot read properties of undefined (reading 'prepare') #4508
Replies: 2 comments
|
I hit the same error with In my case, the ESM fallback resolver passed a declaring package's symlinked The new test reproduces the exact 我在 macOS arm64(Node 22.22.3)上从 在我的环境中,ESM fallback 解析器将声明依赖的包在 上面链接到我 fork 中的 PR 和 commit,包含修复及回归测试:移除修复会重现 |
|
后续更新:0.1.6-alpha.2 的源码启动回归让本帖描述的“重复 完整修复需要同时处理两层:
这样既解决本帖的 profile/plugin 副本问题,也覆盖新的 |
Uh oh!
There was an error while loading. Please reload this page.
Bug: Web mode tool execution fails — "Cannot read properties of undefined (reading 'prepare')"
Bug Description
In
dsh webmode, any agent tool call (e.g.bash) fails immediately with:Cannot read properties of undefined (reading 'prepare')(session recordsturn/endwithreason.kind: "error",code: "UNKNOWN").The UI shows the call as
Interruptedwith ~1ms duration.The same environment works fine in
headlessmode (same profile config, same model, same working directory).Environment
dsh web(http://127.0.0.1:3080), profilewebSteps to Reproduce
dsh web(profileweb)bashtool call (pwd && ls), then the step fails:Cannot read properties of undefined (reading 'prepare')Expected Behavior
The tool executes and the result is returned to the model (exactly as it does in
headlessmode).Actual Behavior
Every tool call in web sessions fails with the
prepareTypeError. Verified across multiple fresh sessions on the same host;headlesson the same host/config/model/dir succeeds.Root-cause analysis (from source)
dsh-agent-loopcallsctx.tools[TOOL_RUNTIME_SCHEDULER].prepare(call.exec)(apps/../packages/agent-loop lib, around line 193).TOOL_RUNTIME_SCHEDULERis a symbol (Symbol("@deepseek-ai/dsh-tools.scheduler"), dsh-tools lib index.js ~2416) whose value is set as an instance field on theToolRuntimeservice ([TOOL_RUNTIME_SCHEDULER] = { ... }in the ToolRuntime class, ~line 2564).headlessthe composed profile has nodsh-agent-presetsplugin (verified: 0 occurrences in--dump-config), so the agent'sctx.toolsis the realToolRuntimeinstance and the symbol property resolves.webthe profile includesdsh-agent-presets(default presetstandard, 2 occurrences in--dump-config). The agent is assembled from the preset, and per the agent-presets docs the agent resolves its service views through the scope hierarchy (agent → preset → global). The scoped view ofctx.toolsdoes not forward the symbol property, soctx.tools[TOOL_RUNTIME_SCHEDULER]isundefined→.preparethrows.Secondary observation: the web profile also ships
tool-bashwithdisabled: true(dsh-web-app layer), yet the model-facing catalog still listsbash— enabling the tool via a user patch (disabled: false) does not fix the crash, confirming the missing scheduler (not the disabled flag) is the primary cause.Suggested fix
dsh-agent-loopaccess the scheduler through a non-symbol key (e.g. a string-keyed accessor) that survives scope proxying.Workaround
Use
dsh --profile headlessfor tool-requiring tasks; web chat works as long as no tools are invoked.All reactions