Repository navigation
Replies: 4 comments
|
这个 bug 我本地已经复现并定位到根因了(dsh 0.1.0-rc.6,Windows 10 专业版,Node 22.23.2),并且已打最小补丁验证修 |
|
你这份自查很到位——找到 一、根因可以再一般化一步:注册进程级注册表的 effect,只有被 dispose 才会撤销你定位的这一句是要害:
不 dispose 旧代际 = 那些 effect 永远不会 unwind = 进程级注册表里永远留着上一代的 provider。 于是新代际 apply 到同一个 provider 名时撞上 这不是 我们(做 DSH 上的外部插件)整套挂载设计就是绕着这条规则建的:所有挂载都走 agent-local 的 (顺带说,那条 TODO 的措辞本身也值得讨论——"等最后一个挂在旧代际上的 agent 消失后再回收"是个正确但复杂的目标。而冲突现在就发生了,不需要等到旧代际真的没人用。也许更小的一步是:新代际 apply 之前,先把旧代际在全局注册表里的那部分撤掉,其余部分再按引用计数慢慢回收。这两件事的紧迫程度不一样。) 二、这个 bug 最贵的部分是那条被吞掉的报错你贴的 API 返回是这样的: {"ok": false, "error": {
"code": "agent-preset-invalid",
"message": "agent-presets: preset \"standard-careful\" failed to mount: failed to apply loader entry tool-cordis (@deepseek-ai/dsh-tool-cordis): Host Cordis inspect provider \"Service\" is already registered (.../agent.cordis.yml)"
}}这条消息里什么都有:哪个 preset、哪个 loader entry、哪个包、什么冲突、哪个文件。任何人看到它都能在几分钟内查到你花了很久才定位的东西。 而 GUI 上的表现是:「新增会话 → 选择工作区 → 闪回未选择状态」,没有任何报错。 也就是说,后端已经把话说清楚了,前端把它扔了。 你原帖写"新建会话链路失败后无明确报错,仅前端状态回滚"——现在你自己的调查证明了那句话应该改成"后端有明确报错,前端没有展示"。这是两个完全不同的问题,后者便宜得多。 我建议把这条单独提出来,因为:
(这也解释了为什么"重启后问题消失"会成为大家的第一反应——在没有任何错误信息的情况下,重启是唯一可行的策略。) 边界与利益相关我们不修 DSH 自家组件—— 利益相关:我维护 pi2dsh(Pi 生态兼容层)。这条不推销——你踩的是 DSH 自己的 preset 代际管理,多装一个插件只会让热重载时要 unwind 的东西更多。 |
|
I came here intending to implement the TODO this report names, and stopped when I found it has no mechanism to hang off. Posting the blocker, because "someone just hasn't written it" and "this needs a lifecycle signal that does not exist" are very different states for an issue to be in. The leak is exactly as described// TODO: reclaim the superseded generation once the last agent joined to
// it is gone. The subtree is not inert — `dsh-skill-filesystem` watches its
// roots — and the settings-page authoring flow turns "a composition
// changed" into a per-save event.
if (this.standing.get(preset.id) === pending) this.standing.delete(preset.id)
return this.ensureStanding(preset)The pointer is dropped and the next generation mounts. The superseded fiber is never disposed, so its Why the prescribed fix cannot be written as statedThe TODO says to decrement "when the agent's scope key dies". Nothing can observe that happening.
A WeakMap gives collection, not notification. So the count the TODO describes can be incremented at every join site it names, and there is no event anywhere at which to decrement it. Two ways out, and both are larger than this issue:
Why a wrong fix is worse than the leakReclamation disposes a subtree an agent may still be joined to. Get the count wrong in the optimistic direction and a live session loses its tools, its skills and its inspect providers mid-turn — silently, because the disposal is the normal teardown path. The current failure is a leak: bounded per save, visible in memory and watcher count, and recovered by a restart. The failure mode of a bad reclamation is an active session degrading with no error. That asymmetry is why I did not want to land a plausible-looking counter here. The thing worth doing first, which is cheapMake the leak observable before making it reclaimable. Right now the only way anyone learns a generation leaked is the collision on this thread — and that signal is about to disappear. The registry collision is being fixed (#4675) so that equivalent providers share one entry instead of the second mount failing. That is right on its own terms, but it means the superseded generation will simply join the live entry and the error will stop appearing. Anyone watching this thread should know that "the error went away" will not mean the leak went away. So a count of standing generations per preset — exposed through the existing inventory/inspect surfaces rather than inferred from a crash — costs almost nothing, needs no lifecycle signal, and turns this from "a thing that announces itself by breaking an unrelated feature" into a number someone can watch. It also makes option 1 above testable if anyone attempts it, which it currently is not. (Verified against |
|
A follow-up that raises the priority of fixing this properly, from a second registry hitting the same leak. #4727 reports The reason that matters here: the workaround being applied to the cordis registry is not available to this one. Making a registry duplicate-tolerant requires deciding that two registrations are the same contract. For Cordis inspect providers that is decidable — a provider is a manifest, declarative data, so a key-order-independent comparison proves equivalence and a genuinely different manifest can still be refused. That is what makes sharing safe there. The system-prompt registry stores something else: readonly text: string | ((context: AssembleContext) => string)and, for variables, There is a partial path: a section whose So for at least one registry the mole cannot be whacked, and the count of affected registries is not bounded by anything except how many process-global registries a preset touches. Every one added later inherits the same latent collision. That is the argument I would put on the leak now: it is not merely that per-registry tolerance is inelegant, it is that per-registry tolerance is impossible for registries whose entries are behaviour rather than data, and those exist today. Whatever the eventual reclamation design, this class does not have a workaround to hide behind in the meantime. It also sharpens the interim ask I made earlier — a count of standing generations per preset. With two registries now known to surface this and no way to make one of them tolerant, an operator currently has no way to tell "my preset edit leaked a generation" from "some plugin registered a duplicate name", and those want completely different responses. |
Uh oh!
There was an error while loading. Please reload this page.
环境
dsh web复现步骤
dsh web(实例长期运行约 4 小时)~/.dsh/profiles/web/cordis.patch.yml,插入 5 个dsh-mcp-client插件(sery/word/docling/filesystem/vision,stdio 传输)——HMR 热重载生效,MCP 进程日志显示全部成功拉起现象
~/.dsh/storages/workspace.json:两个工作区(D:\AI办公、D:\workspace)均已创建(createdAt 正常),但sessionIds全部为空~/.dsh/sessions/<workspace>/下 9 个历史会话全部进入archivedSessionIds附加观察
预期行为
热重载插件配置后,新建会话应正常工作;或至少在热重载时提示需要重启
All reactions