dsh-auto-handoff: Handoff to a new session in the same workspace at Step boundaries of long sessions

Introduction

When running agents in DeepSeek Harness (DSH), as sessions grow long, history gets fed into context repeatedly: Token costs rise with length, and the model’s attention to early content also weakens. Common workarounds include manually starting a new session and copy-pasting progress yourself, or relying on compaction — the former is tedious and prone to missing key decisions, while the latter is not always safe to stop when “the current Step is still running tools or terminal commands.”

dsh-auto-handoff is a community-maintained workflow-class DSH plugin: it ends the current session at a safe Step boundary, writes the task and progress into a structured handoff brief, creates a new session in the same workspace while trying to inherit preset, model, permissions, and Plan mode, and lets the new session pick up where it left off. Triggering can be manual via /handoff, or automatic based on a cumulative session Token threshold. Migration does not hard-interrupt an in-flight Step, Tool Call, file operation, or terminal command — it only refuses to “start the next Step.”

The following covers the plugin’s positioning, capabilities, and installation/usage; facts are based on the GitHub repository README. The DSH ecosystem follows “everything is a plugin”; the SkillHub directory page is an independent community site with no official affiliation with DeepSeek / High-Flyer.

What Is This

  • Name: dsh-auto-handoff (npm package name matches the Cordis plugin name)
  • Maintainer: qingyou002
  • Category: Workflow
  • License: MIT
  • Fact baseline (as declared in the README): @deepseek-ai/dsh@0.1.5-rc.3

The plugin renders nine sections of a long session — “overall goal / constraints / completed / current progress / changed files / key decisions / known issues / unfinished / next steps” — together with the original session configuration read directly by the program, into a fixed-structure handoff brief; the summary portion of the brief is generated by the current session’s own model. The old session is marked as retired and no longer participates in subsequent work.

Core Features

Migration at Step Boundaries, Not Hard Interruption

Migration only happens at Step boundaries: it does not interrupt a running Step, Tool Call, file operation, or terminal command. If the Token threshold or /handoff has already triggered, the plugin waits for the current Step to finish before executing subsequent actions; the stepWaitTimeoutMs timeout only alerts, it does not interrupt.

Two Trigger Modes: Manual and Automatic

Method Description
/handoff Immediately requests migrating the current session to a new session in the same workspace
Token threshold After enabling autoHandoffEnabled, automatically migrates when the session’s cumulative Token count reaches autoHandoffThreshold

There is also an optional Token-threshold auto-compaction (autoCompactEnabled / autoCompactThreshold), which shares the threshold determination and latch logic with auto-handoff; when both switches are on, the compaction threshold must be less than the handoff threshold, otherwise the settings cannot be saved.

Slash Commands

Commands do not enter the model-visible history.

Command Behavior
/handoff Immediate migration
/handoff status Shows stage, cumulative Token and its source, thresholds, auto-action counts, the most recent action and failure records
/handoff cancel Requests canceling an in-progress migration or compaction (effective at the next safe checkpoint)
/handoff retry Retries the most recent failed migration

An empty session (with neither a human prompt nor any turn) will be rejected with the message “there is no active session to migrate”; it will not create an empty session that cannot continue.

Configuration Inheritance

During migration, the following are inherited onto the new session as much as possible:

  • Workspace cwd and workspace attachment (via path-based attachSession)
  • Agent preset, model, permission preset (including approval policies when custom)
  • Plan mode (resolved per agent, per-agent semantics)

Browser-private UI state, temporary models/permissions not yet applied to the session, and the original session’s logs and attachments are not inherited; inheritance results are reported item by item as “inherited / fallback / not inherited (reason).” If sessionController or the llm needed for summarization is unavailable, migration will fail with an explicit error rather than being silently swallowed.

Token Determination and Auto Features

Cumulative metric (session-level; compaction does not reset it to zero):

cumulative = totals.uncachedInputTokens
           + totals.outputTokens
           + totals.cacheReadTokens
           + totals.cacheWriteTokens

Source priority: tokenUsage projection → tokenMeter.measure() estimation → unavailable. When marked unavailable, automatic migration/compaction is disabled; manual /handoff remains available.

Installation and Activation

Install commands come from the repository README; after installation, restart dsh for them to take effect. The package ships with a prebuilt lib/, so installing directly from GitHub does not require adding an allowBuilds whitelist for build scripts in the profile.

# Install directly from GitHub (recommended)
dsh plugin --profile <profile> add github:qingyou002/dsh-auto-handoff

# Or install from a local checkout of the source code
dsh plugin --profile <profile> add "file:/path/to/dsh-auto-handoff"

package.json declares dsh.bundle.patch and dsh.client (platform: "web"); the Host and browser side auto-mount, and the browser half needs no extra profile lines.

The settings namespace is dsh-auto-handoff; if a settings service is available, settings are written to the settings document and persist after restart; if not, they are only valid for the current process. The settings card Slot is settings.plugin.item, with key: "dsh-auto-handoff".

Main Settings Defaults

Field Default Description
autoHandoffEnabled false Token-threshold automatic migration
autoHandoffThreshold 2000000 Automatic migration threshold
autoCompactEnabled false Token-threshold automatic compaction
autoCompactThreshold 1500000 Automatic compaction threshold

To disable all auto features: set both booleans to false; manual commands remain available.

Typical Usage

  1. Install the plugin and restart dsh; enable autoHandoffEnabled in settings and adjust thresholds as needed, or keep the defaults and use fully manual migration.
  2. During a long-running task, run /handoff at an appropriate moment, or wait for the cumulative Token count to reach the threshold; if the Agent is still running a Step, just wait for it to finish.
  3. Use /handoff status to check the Token source (exact / estimated / unavailable) and action status; on failure use /handoff retry, and to abort a queued action use /handoff cancel.
  4. After successful migration, the browser side switches to the new session by default (openNewSessionOnHandoff defaults to true); the new session’s first prompt is the handoff brief, continuing to edit code and run commands in the same cwd.

Use Cases and Notes

Suitable for: Agent tasks within a single workspace that need to run for several hours or more; wanting to switch to a “clean context” without interrupting current tools/terminal; developers who need to carry presets, model, permissions, and Plan mode into the new session.

Important to know:

  • The plugin runs with the permissions of the current dsh process; before installing, please read the source code and LICENSE and assess the trust boundary yourself.
  • Auto features depend on Token metering; when the adapter does not report and the projection is unavailable, only manual /handoff can be used.
  • When both auto switches are enabled, ensure autoCompactThreshold < autoHandoffThreshold; thresholds that are too small (< 50000) will produce a warning but can still be saved.
  • Metadata such as community directory stars may change over time; the GitHub README and local dsh behavior are authoritative.

Conclusion

dsh-auto-handoff solves structured handoff for long sessions: stop at a Step boundary, write a brief, open a new session in the same workspace and inherit key configuration, rather than forcibly cutting off mid-tool-execution. Manual /handoff and the Token threshold share the same implementation, facilitating predictable switching between cost and attention.

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

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

Xiaoye