dsh-session-rescue: A Plugin That Prevents Cold-Start Turn Blocking in DeepSeek Harness

Introduction

In the development and usage of DeepSeek Harness (DSH), after a process restart or loading an existing session, the first turn may become permanently blocked: the UI spins indefinitely, and there are no errors in the logs. This “cold-start turn block” typically occurs during the preStep window between turn/start and step/start, rooted in the synchronous full replay of the session log.

dsh-session-rescue is a session watchdog plugin designed to address this phenomenon. Rather than relying on application restarts, it automates /compact operations to compact the session before its size reaches a danger zone, moving the replay cost out of the user’s turn to ensure service availability.

What is it

dsh-session-rescue is a DeepSeek Harness plugin used to prevent cold-start turn blocking. It works by automating /compact operations to compact sessions before they grow to a dangerous size, and reports session status.

  • Maintainer: 1622352030
  • License: MIT
  • Core Features:
    • Prevents cold-start turn blocking.
    • Compacts sessions before their size approaches the danger zone.
    • Automates /compact operations.
    • Reports status via /rescue status.

How it Works

The plugin addresses replay costs through three core actions:

  1. GUARD: When a session is loaded into the current process and its seq (sequence number) exceeds the danger threshold, automatically compact the session before the user’s first turn (when agent/status becomes idle). This moves the inevitable replay cost out of the turn while shrinking the session size.
  2. COMPACT: Between turns, when the agent is idle, perform a compaction if the session has grown by at least minGrowthSeq since the last compaction. This keeps subsequent cold starts within the seconds range.
  3. Report: Via the /rescue status command, display the seq for each session, whether the current process has paid the replay cost (“warm”) or not (“cold”), and the plugin’s measurements of the preStep duration between turn/start and the first step/start.

Usage

The plugin is primarily used to trigger compaction at specific times and monitor status:

  • Compact by Threshold: Triggers compaction when the session sequence number seq exceeds the danger threshold.
  • Compact during Idle: Triggers compaction between turns when the agent is idle, provided the session growth reaches the configured value.
  • Status Check: Use /rescue status to check the session’s warm/cold status and preStep duration.

Configuration

To enable this plugin in the DSH configuration file, set the following parameters. The default thresholds are calibrated based on measured data (approx. 16 seconds for a cold start at 40k, potential permanent blocking at 80k).

- insert:
    - id: session-rescue
      name: dsh-session-rescue
      config:
        enabled: true        # false = observe and report only, never compact
        warnSeq: 40000       # Start warning/compacting from here
        dangerSeq: 80000     # Exceeding this may cause the first turn of a cold start to never return
        minGrowthSeq: 20000  # Only trigger after growing this amount since last compaction
        cooldownMs: 60000
        maxAttemptsPerSession: 6
        maxBusyStreak: 5
        pollMs: 30000
        compactionTimeoutMs: 600000

Technical Details & Notes

  • Environment Requirements: Requires Node.js version >= 22.15.
  • Immutable Fact: Full replay is inevitable, but the location where the replay cost is paid (inside the user’s turn vs. during idle periods) can be changed. Once compaction is performed, subsequent cold starts remain cheap.
  • Trigger Mechanism: The trigger condition for compaction is the growth delta, not absolute size. This prevents infinite repeated compactions during idle periods.
  • Sequence Number Limitation: Compaction operations do not reduce session.seq because logs are append-only.
  • Status Reporting: If the core returns a busy status (indicating a compaction is already running or the agent is not idle), the plugin will not mark the session as “warm”, to avoid cold sessions missing the guard check.

Conclusion

dsh-session-rescue provides an engineered solution for handling cold-start blocking in DSH. By automating /compact, it distributes and front-loads the synchronous replay cost that could otherwise lead to permanent blocking. Combined with status monitoring, it provides necessary safeguards for maintaining long sessions.

  • GitHub Repository: https://github.com/1622352030/dsh-session-rescue
  • Plugin Directory: https://www.skillhub.cn/plugins/1622352030/dsh-session-rescue
羽毛球分组比赛记分
小程序二维码

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

Xiaoye