Preface¶
In agentic development in 2026, the context window remains a hard constraint. When conversations become lengthy or tool outputs (such as code analysis or log exports) exceed 8192 characters, token consumption climbs rapidly. dsh-headroom is a local proxy plugin designed specifically for DeepSeek Harness (DSH). By managing a local Python service, it automatically compresses historical conversations and large tool outputs in the background, reducing token burn without losing semantics. The plugin is unofficial, maintained by community developer WanYanTianDe, and licensed under MIT.
Installation and Activation¶
The simplest way to install the plugin is via npm. Run the following command in the ~/.dsh/profiles/web directory:
pnpm add @wanyantiande/dsh-headroom
After installation, you need to edit the ~/.dsh/profiles/web/cordis.patch.yml file to register the plugin:
- insert:
- id: dsh-headroom
name: '@wanyantiande/dsh-headroom'
Save the file and restart the DSH Web interface. On the first run, the plugin will automatically prepare the local compression service; the initial model file download requires approximately several hundred MB of space. If you need to install from source or perform local development, you can clone the repository and run node scripts/install.mjs.
Core Features¶
The plugin mainly consists of the following five components:
- Proxy Lifecycle: Upon startup, the plugin probes
127.0.0.1:8787. If no service is found, it attempts to auto-install viauv tool install headroom-ai[all]and then starts theheadroom proxyprocess. Once the proxy is healthy,ctx.headroomClientis mounted. When settings change, the plugin restarts the proxy serially (reusing the old proxy unless configuration changes force a replacement). Upon uninstallation, it cleans up the process tree. - History Compression: When conversation token pressure or overflow occurs, the plugin selects a historical range, compresses it via the local proxy’s
/v1/compressinterface, and writes the result into the session’s checkpoint. This inherits the transaction and persistence mechanisms of the Harness compression backend. - Tool Output Compression: At the step boundaries of model requests, the plugin checks if tool outputs exceed a threshold (default 8192 characters). If so, it compresses them and shadow-replaces them with the compressed text, keeping the original in the session log. Replacement only occurs if the compression savings exceed 20% (default) or if a proxy is available.
- Retrieval Tool: The plugin provides a
headroom_retrieve(hash)tool. The model can call this tool when details are needed to retrieve the compressed original text by hash via thePOST /v1/retrieveinterface (applicable to both history and tool outputs). - Configuration Command: Provides a
/headroomconversation command for viewing and modifying compression settings.
Configuration and Usage¶
The plugin supports two configuration methods: conversation commands and configuration files.
1. Conversation Command (Recommended)¶
Enter the following commands in any session to view or modify configuration:
/headroom # View current configuration
/headroom set port 9000 # Modify port number
/headroom set autoInstall true # Modify boolean values
/headroom unset port # Restore default
Configurable keys include port, baseUrl, command, pythonPath, uvCommand, autoInstall, resultCompressionEnabled, resultCompressionThresholdChars.
2. Configuration File¶
You can also directly modify ~/.dsh/settings.yaml or the plugin’s config section. Key configuration items are as follows:
headroom:
port: 8787
autoInstall: true
config:
compressMode: 'ccr' # Use CCR mode to allow retrieval of original text
prewarm: true # Pre-warm model on startup
headroom:
savingsProfile: 'coding' # Compression profile
kompressMustKeep: true # Whether to preserve numbers and paths (set to false for higher JSON compression rates)
resultCompression:
minSavingsRatio: 0.15 # Minimum savings ratio for tool output compression
maxPerStep: 3 # Maximum number of compressions per step
thresholdRatio: 0.8 # Threshold for history compression pressure
auto: true # Auto-compression switch
3. Settings Card Limitations¶
The plugin provides a “Headroom Compression” card in the DSH settings panel. Due to the Harness WEB_SETTINGS_NAMESPACES whitelist restriction, external plugins cannot configure via the settings card by default. If the card is not visible, please use the /headroom command or the configuration file directly.
Performance and Limitations¶
- Compression Mechanism: Compression follows the Harness shadow node protocol; messages are reconstructible, and the session log is the single source of truth.
- Safety: If the compressed result is larger than the original, the transaction fails and retains the original text. The plugin guarantees a minimum savings floor of 0%, ensuring it is never worse than not having it installed.
- Conflict Handling: When the plugin is enabled alongside Harness’s
compaction-basic, the plugin automatically takes over the assembly entry forcompaction-basic, requiring no manual intervention. - Non-bundled Code: The plugin itself does not contain headroom’s code but installs its distribution via
uvand invokes the local service.
Measured Performance Data¶
According to measured data provided in the README, compression benefits under different configurations are as follows:
- Lossless Path (default config): Chinese prose approx. 52.6%, English/Mixed approx. 24.3% ~ 33%.
- Kompress Lossy Path (0.3.0+, default profile): Chinese prose approx. 33.5%.
- JSON Compression:
- Default
mustKeep: approx. 9%. - Aggressive mode (
kompressMustKeep: false): up to 96.6% (but precise values are lost, requires CCR retrieval).
- Default
FAQ¶
- What if it fails to install? First try installing the service manually:
uv tool install "headroom-ai[all]". - Will content be lost? No. All original text is saved locally, and the model retrieves it via
headroom_retrievewhen needed. - How is it different from dsh-compressor? dsh-headroom provides both history compression and tool output compression, whereas dsh-compressor only compresses tool output.
Summary¶
dsh-headroom is a practical tool for solving long-context token consumption issues. It automatically manages the compression lifecycle via a local proxy and utilizes the CCR mechanism to ensure content reversibility. For agentic developers dealing with long conversations or large volumes of structured data output, installing this plugin can effectively reduce costs and maintain long-horizon reasoning capabilities.