dsh-preset-reload: Hot Reload Agent Presets without Restarting dsh

Introduction

When modifying an agent preset in DeepSeek Harness (DSH)—such as plugin code, a persona card, or a definition file—newly opened sessions typically receive the new revision, but sessions that are already running remain bound to the old revision. The bindings in the registry are stored in a WeakMap, making them impossible to iterate over and rebind; mount() reuses existing revisions, and bind() returns immediately if it encounters the same revision. The result is: changing a single line of text often requires a process restart, and long-running bots can lose context en masse.

dsh-preset-reload (maintained by CK-Rebi) bridges the gap of “moving live Agents to a new revision after definition updates”: it rebuilds the preset revision and rebinds running sessions, preserving sessionId and context without requiring a dsh restart.

What is this

  • Name: dsh-preset-reload (npm package name is the same as the repository name)
  • Category: Workflow (Community Directory SkillHub Plugin Page)
  • One-liner: Hot-reload a DeepSeek Harness agent preset: rebuild its revision and rebind running sessions, without restarting dsh.
  • Source & Docs: GitHub - CK-Rebi/dsh-preset-reload, MIT License; current package version 1.0.1, requires Node >=20.

How it works

After a definition file (e.g., the cordis.patch.yml generated by your build) changes, the plugin performs roughly two tasks within a configurable debounce window:

  1. (Optional but enabled by default) Performs a disable → enable on the target preset line, causing Service.init to rerun and register() to produce a new revision—merely changing config does not guarantee re-registration; this is the deterministic trigger under current DSH mechanisms.
  2. Calls recompose(agent.ctx, presetId) to migrate live Agents of the same preset to the new revision.

For mechanism details and source explanations, see docs/why-force.md in the repository.

Core Features

  • File Watching + Debounce: Watches files or directories under roots, merging continuous events with a default debounceMs of 800ms.
  • Automatic or Manual: When auto: true, saving the definition file triggers it; you can also invoke the tool preset_reload in any session.
  • Forced Remount (force): Defaults to true, using disable→enable to ensure a new revision; force=false performs a lightweight reconcile, which may not push through old bindings.
  • Audit Logging: Optional logFile records the trigger source, whether the revision was updated, and which sessions were rebound.
  • Failure Isolation: Preset mount failures are recorded in record.broken without causing profile startup failure; live sessions continue on the old revision, and corrupted definitions are not accepted by recompose.

Verification records (README): On DSH 0.2.0-rc.2, after recompose, the tool table switched from a stale binding to the new definition; ?v= hash changes loaded new modules after rebinding; changing definition files in a real dsh web instance resulted in automatic remount and rebinding without a restart.

Installation and Activation

The plugin runs with the permissions of the current dsh process. Please review the repository source code and MIT license before installing.

Method 1: Install as a bundle

dsh plugin --profile web add github:CK-Rebi/dsh-preset-reload

Once installed, configure it in the profile’s patch (example):

- id: preset-reload
  config:
    presets:
      - your-preset-id
    roots:
      - '/path/to/your/bundle/cordis.patch.yml'

Method 2: Manually add a line (no package installation)

In ~/.dsh/profiles/<profile>/cordis.patch.yml, use an absolute file:// path pointing to the repository’s index.mjs:

- insert:
    - id: preset-reload
      name: 'file:///path/to/dsh-preset-reload/index.mjs'
      config:
        presets:
          - your-preset-id
        roots:
          - '/path/to/your/bundle/cordis.patch.yml'
        force: true

The insert must be placed at the host layer (the profile’s patch). Do not place it inside the preset, otherwise it will replace itself every time a remount occurs.

Configuration Options

Field Type Default Description
presets string[] [] List of preset IDs to reload
roots string[] [] Paths to watch, can be files or directories
debounceMs number 800 Quiet window for merging file events (milliseconds)
auto boolean true If false, only the preset_reload tool can trigger it
force boolean true Whether to disable→enable to force a new revision
logFile string '' Audit log path; empty string disables file writing

It is recommended to specify only definition files in roots, not entire directories, otherwise saving unrelated modules will trigger a full-tree remount.

Typical Usage

Auto Reload

Simply have your build script regenerate the definition file, for example:

node scripts/build-preset.mjs

After the debounce period ends, the plugin completes the remount and rebinding. If the build recalculates the ?v= content hash for module URLs, please run the script directly; the README mentions that piping the build in some environments may cause the script to silently fail to write files.

Manual Reload

Invoke the tool within a session:

preset_reload                        # Uses presets from config
preset_reload presetId=your-preset
preset_reload force=false            # Lightweight attempt, may not push through

The return example meanings: forced (whether the forced path was taken), changed (whether the revision changed), moved (sessions rebound); rebinding is not gated by changed.

Use Cases and Notes

Suitable for: Long-running DSH bots, frequent modifications to preset plugins or persona cards, scenarios requiring fewer restarts during development, and multi-session online environments.

Scope: Only handles hot-reloading of preset-layer plugins; installation/upgrade of host-layer plugin packages is outside the scope of this plugin (can coexist with dsh-hot-installer).

Known Limitations (from README):

  • Forced remount rebuilds the preset’s Cordis subtree; ongoing turns may see a transient switch in the tool table. It is advisable to make changes during idle times or accept the switch.
  • There is a millisecond-level window between the disable and enable phases of force, during which new sessions might not find the preset.
  • Modules are cached by URL (including query strings); if you change a module but do not update the hash in the definition, old code may still be loaded.
  • Peer dependencies such as @deepseek-ai/dsh-app-boot cover multiple version ranges and must match the current DSH version.

The DSH ecosystem emphasizes “Everything is a plugin”; the community directory SkillHub is an independent site and has no official affiliation with DeepSeek / High-Flyer.

Conclusion

dsh-preset-reload addresses the gap where “new sessions use new code, but old sessions stick to old revisions.” By watching definition files, performing optional forced re-registration, and using recompose to rebind, it delivers preset changes to online sessions without touching the sessionId. For installation and configuration details, please refer to the SkillHub Directory Page and the GitHub Repository README.

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

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

Xiaoye