Bundle
dsh-zombie-gc
One-shot zombie-agent GC: at boot, find agents flagged running whose session log already ended (turn/end + session/end-seed) and settle them (agent.cancel + whenIdle) so the client never subscribes to a phantom running session.
- Source
- DosterBool
- License
- MIT
- Updated
- Updated 4 days ago
Readme
# dsh-zombie-gc · 僵尸 agent 清理
DeepSeek Harness (dsh) 插件:**开机自动清理"已收尾但 agent 仍挂 registry"的僵尸会话**,防止客户端"退出重进后输入框卡死"。
## 背景:这个 Bug 是什么
dsh 0.1.1 启动时会恢复所有持久化会话(restore 机制,为每个会话补写 `session/end-seed`)。恢复的"已结束"会话在 agents registry 里被挂上 live agent 条目——但该 agent 没有活干,处于**空闲僵尸态**(registry 保留它,这是缓存复用设计,不清理)。
之后用户**退出再进入**该会话:客户端订阅到僵尸 agent → 输入相位被锁 → 输入框表现为"能聚焦但打不进字"。日志证据:会话以 `turn/end + session/end-seed` 正常收尾(挂起回合 = 0),列表却显示 `running: True`。
## 工作原理
插件在 bundle 挂载 12 秒后(等待恢复过程完成)执行一次:
1. 枚举 `agents` registry 里有条目的会话
2. 从会话对象自带 log 读事件尾部,判定是否已正常收尾(回扫最后 30 条:遇到 `turn/end`/`session/end-seed` → 已结束;遇到 `turn/start`/`step/start`/`agent/request` → 仍在跑)
3. 已收尾的调用 `agent.cancel({ kind: 'user' })` + 等待 `whenIdle`,让 agent 结算退出
**绝不触碰真正运行中的会话**(尾部仍是进行态事件的会被跳过)。
## 安装
```sh
dsh plugin --profile web add file:D:/path/to/dsh-zombie-cleaner
```
重启 DSH 生效。插件本身零依赖(只需 Node 24 的 node:zlib)。
## 已知边界
- running 红点标记可能仍显示(agent 空闲态计算结果显示,不影响功能)。这是 registry 缓存复用的设计,非本插件可清
- 只清理"日志已收尾"的确定性僵尸;运行中的会话一律保留
## License
MIT
Install
dsh plugin --profile web add github:DosterBool/dsh-zombie-gc
Profile: web
With the hub plugin installed, ask your agent to install it by name — it resolves the same plan shown here.
dsh plugin --profile web add github:stvlynn/dsh.fish#path:packages/dsh-plugin-hub
install dsh-zombie-gc from the hub
- This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.