dsh-host-restart: Restart DSH and automatically resume current session

Preface

After modifying host plugins, cordis.patch.yml, or dependency packages in DeepSeek Harness (DSH), you often must restart the process for the new code to be loaded. Cordis caches imported modules by URL, so changes to files like lib/*.js specifically require a restart. The problem is: manually killing the process and restarting it interrupts ongoing conversations, and users have to re-establish the context.

The common practice involves closing the window, refreshing the page, or writing custom scripts to launch the process, but session recovery and message continuation usually require a separate mechanism. Below is an introduction to the community plugin dsh-host-restart (Maintainer: liuyun847, npm package name dsh-host-restart, current version v0.8.0, MIT License). It registers the model tool restart_dsh and the manual command /restart on the host side, combining “killing the current instance → launching a new process → recovering the originating session and injecting a fixed continuation sentence” into a single step.

What is this

dsh-host-restart is a DSH Host Plugin (Category: Workflow) that registers tools and commands with the host via cordis.patch.yml. It does not extend business logic; it solely solves the “continue chatting after restart” issue: before restarting, it can optionally call slHandoff.saveAll provided by dsh-host-sl (under the same profile) to refresh the SL worksheet; after restarting, it re-attaches to the originating session via sessionController.resolveAgent and injects the fixed text dsh已重启,继续 (since v0.5.0, the tool has no arguments, and the text is not configurable).

In terms of implementation, it relies on the PowerShell driver script dsh-restart.ps1 on Windows (using WMI to start outside the dsh process tree). The timing and troubleshooting in the README are based on a Windows + web or Electron desktop host. The community directory SkillHub marks this plugin as installable; SkillHub is a community site and has no official affiliation with DeepSeek or Hi-Focus (Huanfang). The DSH ecosystem itself is “everything is a plugin.” Before installing, it is recommended to read the source code and license on GitHub, and understand that the plugin executes restart and disk write operations with the permissions of the current dsh process.

Core Features

Two entry points, one workflow

Since v0.7.0, in addition to the model tool, users can also type /restart directly in the input box. Both entry points share the execution body performRestart (session validation → activity detection → handover save → write marker → start driver script), differing only in the prefix for failure/success messages. /restart is registered via the official commands service; if the service is absent, it only logs an entry and does not affect the restart_dsh tool.

The model-side call form is a no-argument tool:

restart_dsh()

The tool return will request the model to immediately end the current output; the entire restart process takes approximately 11 seconds (no watchdog, self-launching) to 26 seconds (watchdog handover) in README tests. The model-side description also mentions a magnitude of about 20–40 seconds, so waiting time should be factored in.

Before Restart: Notify, do not block

Since v0.4.0, when detecting that other sessions still have “in-flight” activities (the current session’s turn is running, child agents under it are running, or background jobs under it are unsettled), the plugin no longer refuses the restart. Instead, it simply names the session ID, the reason, and whether the handover was saved in logs and tool returns, and proceeds as usual. The trade-off is: the ongoing tool call step in the interrupted session cannot be recovered.

Before Restart: Optional SL Handover (v0.8.0 Contract)

If dsh-host-sl is loaded, the first call to the restart entry point will probe the slHandoff service and call:

saveAll({ all: true, noteSessionId, session })

The service side takes up to 5 seconds to refresh, and this plugin waits for up to 7 seconds; v0.8.0 waits for the submission result and reports the actual session ID and refresh completeness in the return text. Job-only sessions are not included in the table, and recovery by SL is not guaranteed; if the service is absent, fails, or times out, the restart is not blocked.

After Restart: Session Recovery and Injection

The plugin reads $DSH_HOME/storages/dsh-restart/pending.json after the new process applies, with a default delay of 4 seconds (bootDelayMs), and then recovers the session corresponding to sessionId.

If the pending continuation markers of dsh-host-sl already contain unhandled entries for this session, this plugin yields. The injection will be performed by the SL plugin’s 【sl handover continuation】 (the beginning of the body contains “dsh restarted”). After approximately 10 seconds, a fallback check is performed; if the other party has not taken over and the session is still not running, the same fixed text is injected. If there is no handover record, it directly calls followup("dsh已重启,继续").

Web Host vs. Electron Desktop (v0.6.0)

Dimension Web Host Electron Desktop
Kill Process Targets the node of this instance + dsh\lib\bin.js Entire DeepSeek Harness.exe process tree under the same install path
Launch Watchdog handover or script self-launches node bin.js Cold start of the same exe after old process fully exits
Session Continuation Same as Desktop (marker + resolveAgent + injection) Same as above

The desktop version only kills instances under the same exe installation path to avoid damaging other installations.

Hard Boundaries (Calls will be rejected or require awareness)

  1. Main Session Only: Rejected if session.header.origin === 'subagent' or session ID is unavailable; no marker is written, and no restart occurs.
  2. Kill Own Instance Only: If driver script identity resolution fails (exit code 4), no processes are killed.
  3. In-flight sub-agents and background jobs will be hard killed, resulting in loss of results; job-only sessions will not be automatically recovered.
  4. Model tool description requirement: Use only when the user explicitly requests a restart.

Installation and Activation

The README does not provide a standalone dsh plugin add … one-liner command; installation can be done via the community directory page (currently showing v0.8.0, sourced from GitHub):

After installation, toggle on the master switch for the dsh-host-restart card in the DSH Web Sidebar “Plugins” page → “Installed” section (written to dsh.profile.bundles). The card also contains row-level switches; you can override restart-dsh in the profile’s cordis.patch.yml by setting disabled: true.

Note: After modifying lib/*.js, you must go through another dsh restart for the new modules to load; therefore, the /restart feature in v0.7.0 is also only available after “the next restart”. The config section in the package’s cordis.patch.yml is optional (e.g., bootDelayMs, staleMs, restartScript); invalid values will fail loud and not register the tool.

Uninstall example (README rollback process, replace <profile> with your profile name, e.g., desktop):

node <workspace>\dsh\dsh-plugin-manager\dshpm.mjs remove dsh-host-restart --profile <profile>

If pnpm remove reports a supply chain policy error, you can execute in the profile directory:

pnpm remove dsh-host-restart --config.minimum-release-age=0

Typical Usage

1. Let the model restart after modifying plugin code

Explicitly state in the conversation that a DSH restart is needed to load new code, and let the model call restart_dsh(). After a successful call, the model should stop the current output; within ten seconds to half a minute, the same session should receive a continuation message (fixed sentence or SL handover sentence), without manual refresh or context repetition.

2. User direct restart

Send in the input box:

/restart

The behavior is consistent with the tool, but it does not send a prompt like “please end this reply immediately” to the model.

3. Collaboration with dsh-host-sl

If dsh-host-sl is enabled in the profile simultaneously, saveAll will be attempted automatically before the restart; after the restart, if there are unhandled SL handover entries, the continuation is dominated by the SL plugin to avoid two conflicting user messages appearing in the same turn. If only restart is installed and SL is not, the fixed dsh已重启,继续 injection is still used.

4. Local Development and Verification

The process provided by the maintainer in README §7 includes: modifying source code under plugins\dsh-host-restart in the profile, running tests, verifying hard links/hashes, and initiating a restart. The test suite is located in the repository:

node --test "test/*.test.mjs"

(The README recorded 131/131 test cases passing for v0.7.0.)

Scenarios and Precautions

Who is it for

  • Developers who frequently modify DSH host plugins, cordis.patch.yml, or this package’s own code, and do not want to manually kill the process and lose sessions every time.
  • Users already using DSH web or the official Electron desktop on Windows, and willing to let the model or /restart handle the restart.

Please confirm before use

  • The plugin terminates the current DSH instance (the entire application tree for the desktop version) with permissions identical to the current user; please read the GitHub repository source code and MIT license before installing.
  • Do not rely on unsaved child agent or background job results during the restart window.
  • Driver scripts and logs default to the tool directory (e.g., dsh-restart.log, pending.json); the web self-launch path will write dsh-last-url.txt (URL with token, usable when clearing cookies).

Conclusion

dsh-host-restart binds the high-frequency DSH development tasks of “restart for code changes” and “session continuation” into a single step: restart_dsh and /restart share the same workflow, optionally integrate with dsh-host-sl’s worksheets and handover injections, and distinguish between web and desktop process killing/launching semantics. For installation instructions and version information, see the SkillHub Directory Page; for mechanism details, configuration items, and troubleshooting, refer to the GitHub README.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye