前言¶
在 DSH Web profile 裏,有兩個連續性問題比較常見:回合被中斷後,空提交本身不會被識別爲繼續;進程 shutdown 後,shutdown 時仍標記爲 running 的會話和子代理也不會自動恢復。
上游 DSH 已提供 resumeSessionId、interrupted-turn closers、checkpoints 和 session persistence,但空提交繼續以及按 shutdown 集合恢復會話/子代理的行爲並不完整。下面介紹 dsh-resume。
這是什麼¶
dsh-resume 是 xiaohj233 維護的 DSH 插件,許可爲 MIT。當前安裝示例使用版本 v0.2.1,狀態爲 Feature Plugin with Compatibility Patch,測試範圍爲 DeepSeek Harness 0.1.0-rc.6。
它主要解決兩件事:
- 被中斷的 DSH 對話可以通過空提交繼續。
- DSH 進程 shutdown 時記錄爲 running 的會話和子代理,可以在下次啓動時恢復。
核心功能¶
空提交繼續¶
- 當回合被中斷時,將已收到的 partial text 和 reasoning 折入 session history。
- 支持通過 empty submit 繼續被中斷的 DSH 對話,而不添加可見的 “continue” 消息。
- 使用官方
agents.resumeservice,並通過兼容補丁添加 partial-turn folding 和 empty-submit handling。
shutdown 後恢復¶
- 將會話和子代理的活動狀態記錄到
~/.dsh/resume-state.json。 - 僅恢復 shutdown 時記錄爲 running 的會話和子代理;completed 或 user-aborted turns 不恢復。
- 成功恢復的會話立即原子寫入並從持久化集合移除,失敗恢復保留記錄並在下次啓動重試。
- 啓動時自動重試記錄的子代理,失敗條目可通過
resume_interrupted_subagents使用。 - 恢復診斷寫入
~/.dsh/resume-state.log。
兼容補丁與版本策略¶
兼容補丁目標包括:
@deepseek-ai/dsh-agent-loop@0.1.0-rc.6
@deepseek-ai/dsh-session@0.1.0-rc.6
@deepseek-ai/dsh-client-ui-conversation@0.1.0-rc.6
補丁目標 hunk 冪等,並有顯式 reverse operation。默認使用 adaptive 版本策略;程序化 strict 選項可恢復 exact-version-only apply 行爲。
安裝與啓用¶
先添加插件:
dsh plugin --profile web add "github:xiaohj233/dsh-resume#v0.2.1"
安裝後重啓 Web profile。
如需覆蓋配置,可以調整 profile patch 中的 dsh-resume 行:
- id: dsh-resume
config:
enabled: true
restoreDelayMs: 2000
卸載與上游升級¶
卸載前先恢復官方包文件,再移除插件:
pnpm --dir "$DSH_HOME/profiles/web" exec dsh-resume-restore
dsh plugin --profile web remove dsh-resume
上游升級後運行 dsh-resume-restore 和 verify:anchors 一次,確認每個 hunk applied 或 intentionally skipped。
測試命令:
npm test
npm run check
npm pack --dry-run
兼容性¶
- Node.js:
^22.19.0 || >=24 - pnpm:
>=10
適用場景與注意¶
適合在 DSH Web profile 中遇到以下情況的用戶:
- 希望被中斷的對話可以通過空提交繼續。
- 希望在進程重啓後恢復 shutdown 時仍 running 的會話和子代理。
- 希望保留恢復診斷日誌,而不是隻依賴上游已有 session persistence。
插件以當前 dsh 進程權限運行,安裝前應檢查源碼、依賴和許可證。
resume-state.json 和 resume-state.log 包含 session/subagent identifiers、model 和 recovery diagnostics、failure messages;不故意存儲 credential values,但應作爲 private runtime data。自動恢復可能發起新的 model requests,併產生 provider usage。
該插件不處理以下事項:
- 不導入其他 agents 的 sessions。
- 不 rewind arbitrary turns。
- 不 migrate workspaces。
- 不保證 remote provider 可以 byte-for-byte reproduce interrupted stream。
- 不修復所有 upstream session-log race。
上游 DSH Discussion #420 記錄了一個 dsh-resume 不聲稱消除的 race。
結尾¶
如果你的主要需求是恢復被中斷的 DSH 回合,並在進程重啓後恢復 shutdown 時記錄爲 running 的會話和子代理,dsh-resume 可以作爲 DSH Web profile 的連續性補丁。