dsh-zcode-breaker: Fast-Fill Circuit Breaker for Automated Compression in DeepSeek Harness

Preface

DeepSeek Harness (DSH)’s automatic compaction mechanism has a specific issue on the “pressure” path: there is no attempt ceiling, causing a futile “rapid refill” loop where an oversized file read or tool output consumes a summarization call at every step. dsh-zcode-breaker aims to address this by halting that loop before summarization is wasted.

Core Features

This plugin extends BasicCompactionEngine and wraps the compactIfNeeded method. It provides the following capabilities:

  • Session-scoped state: State is managed per session, preventing cross-session contamination.
  • Log-driven detection: Reads tool turns from the persistent session log (assistant messages carrying at least one tool call) rather than using an internal counter. This is the unit used by the compaction seam for balancing computation.
  • Rapid refill detection: If compaction is requested after fewer than toolTurnThreshold tool turns, it is treated as a rapid refill.
  • Early rejection: When maxConsecutiveRapidRefills is reached, the attempt is rejected before the summarization call runs. This rejection is latched; once triggered, the session remains in a rejecting state until reset.
  • Error handling: Throws CompactionRapidRefillError with actionable suggestions.
  • Visibility: Since DSH’s host catches errors from compactIfNeeded and continues the turn, the plugin injects a hint section during the latched period to ensure the stop is visible.
  • Admin commands: Provides the /compaction-breaker command to report state and reset the breaker.

Installation & Configuration

Installing this plugin requires the following dependencies:

  • DSH version >= 0.1.5-rc.2 and >= 0.1.6-alpha.1
  • @deepseek-ai/cordis ^4.0.2
  • @deepseek-ai/dsh-compaction-basic
  • @deepseek-ai/schemastery ^3.18.2

The installation command is:

dsh plugin --profile web add dsh-zcode-breaker

Typical Usage

After installation, you can use the following commands to inspect plugin state:

/compaction-breaker status
/compaction-breaker reset

The plugin includes a test suite for verifying the state machine logic and wrapper behavior:

node --test test/tracker.test.js
node --test test/engine.test.js
node tools/boot-check.mjs --port 32100

Implementation Details

This plugin takes the rapid refill state machine logic from the ZCode implementation, but improves on it:

  • Log reading: Unlike ZCode, which maintains a counter in a loop, this plugin reads tool turns from DSH’s persistent session log to match the measurement unit used by the compaction seam.
  • Lock timing: The rejection logic occurs before the summarization call runs (latching), rather than after.
  • Configurability: Thresholds (toolTurnThreshold, maxConsecutiveRapidRefills) are provided as line configuration, rather than compiled-in constants.
  • No microcompact implementation: This plugin explicitly does not implement ZCode’s microcompact.ts logic, as it does not reimplement that logic.

Caveats

  • Node version: Although package.json declares >=20, running npm install on Node 20 yields 10 packages with no dsh binary, while on Node 24 it yields 488 packages. The badge shows a measured value of Node >=22.19.

Summary

dsh-zcode-breaker directly addresses a specific issue in DSH’s automatic compaction by preventing the compact-refill-compact loop from wasting summarization resources. It does so by rejecting rapid refills before the call runs and reading tool turns from the persistent log for accurate state tracking.

Catalog page
GitHub repository

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

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

Xiaoye