Foreword¶
In the plugin-based development system of DeepSeek Harness (DSH), service restarts are a common scenario. A restart often causes the current session to be interrupted and in-progress tasks to be lost. To address this problem, this article introduces a workflow plugin that, after detecting a DSH service restart, automatically sends an informational message to the main agent. This message includes the interruption duration and a summary of the last active session, allowing the agent to independently decide whether to continue the previous work or start a new task, instead of being mandatorily forced to resume.
What Is This¶
dsh-resume-on-restart is a DSH plugin maintained by user nickkkkkk123123. It solves the core problem of “lost sessions and work after a DSH restart.” By delivering a status summary at restart, it enables the agent to make reasonable decisions based on context after the restart.
Core Features¶
The plugin mainly includes the following capabilities:
- Restart Detection: It determines whether the current DSH instance has been restarted by reading a marker file that records the previous process pid and boot time.
- Informational Message: After detecting a restart, it delivers a summary message containing “restart detected + interruption duration + last active session.” This is an informational hint and does not force the agent to perform a specific action.
- Activity Tracking: During DSH runtime, it records the most recently active session by listening to cordis events (such as
agent/session-startandagent/pre-step) for use in post-restart messages. - DSH Desktop Compatibility: The plugin only depends on the cordis context (
agentsservice) and does not import any@deepseek-ai/dsh-*internal packages, so it can run normally in packaged DSH Desktop environments (such as app.asar).
Installation and Enablement¶
Before installation, please ensure that the DeepSeek Harness CLI is installed. When installing, specify the local path.
# 将插件安装到桌面 profile(DSH Desktop 默认使用 desktop profile)
dsh plugin --profile desktop add <本目录路径>
# 安装完成后,重启 DSH Desktop 即可生效
Configuration¶
The plugin configuration is managed through the cordis.patch.yml file. The following are the key configuration items and their default values:
| Config Item | Default Value | Description |
|---|---|---|
enabled |
true |
Master switch for the plugin. |
stateDir |
.resume-on-restart |
Directory for marker files and state files (relative to DSH_HOME). |
target |
primary |
Message delivery target. The default is the main agent (primary); a specific session ID can also be specified. |
wakeup |
true |
Whether to actually wake up the target agent after delivering the message. Set to false to only inject the message. |
notice |
'' |
Custom notice text appended to the end of the message. |
shutdownGraceMs |
600000 |
Grace window before shutdown (in milliseconds). During this period, sessions marked as active are considered task-related. |
ignoredSessionPrefixes |
['head-'] |
Session ID prefixes that need to be ignored (for example, root sessions in multi-agent architectures). |
Execution Logic¶
The execution flow when DSH starts is as follows:
- Read Marker: Read
~/.dsh/.resume-on-restart/marker.jsonto obtain the previouspidandlastBootAt. - Determine Restart: Compare the current process
pidwith thepidin the marker. If they do not match, a restart is considered to have occurred. - Update Marker: Write a new marker file with the current
pidand boot time. - Deliver Message: If a restart is detected, the plugin polls and waits for the main agent to appear (up to 20 seconds), then delivers the informational message. The message format is typically as follows:
[resume-on-restart] 检测到 DSH 服务已重启。
上次运行于 ...,本次于 ... 重启完成。
中断约 X 秒。
重启前最近活跃的会话:<session-id>
如需继续之前的工作,或启动新任务,请自主决定下一步。
Applicable Scenarios and Notes¶
- Applicable Scenarios: Users who need to run DSH Desktop for extended periods and want to recover workflows after an unexpected restart.
- Permission Notice: The plugin runs with the permissions of the current DSH process. Please ensure that the installation source is trustworthy.
- Source Code Review: Before installing any community plugin, it is recommended to review its source code and license. This project uses the MIT license.
Closing¶
This plugin addresses the loss of context after a DSH restart through lightweight state tracking and message delivery. It does not replace the agent’s logic but provides the basis for decision-making, which aligns with DSH’s architectural philosophy of “everything is a plugin.”
Plugin Directory: dsh-resume-on-restart
Source Repository: GitHub