Preface¶
The context compaction mechanism in DeepSeek Harness (DSH) is used to handle long conversations by compressing earlier dialogue into checkpoints to save tokens. The official default backend is dsh-compaction-basic, whose summarization prompt is a generic English template and has two main problems: first, it can easily lose exact values (such as version numbers, file paths, command strings, and error strings), which is fatal for quantitative or programming agents; second, it forces English output, causing a fragmented reading experience in Chinese conversations.
dsh-compaction-pro is a high-fidelity, bilingual, recursive context compaction backend plugin. It only overrides the core summarize() hook, while all other pressure/retention/token metering strategies fully inherit the official implementation, serving as an upgraded replacement for dsh-compaction-basic.
Installation and Enablement¶
Install it using the official command-line tool:
dsh plugin --profile web add dsh-compaction-pro
After installation, you must register it in the configuration file and disable the built-in backend; otherwise, a service conflict may occur.
- Open the configuration file
~/.dsh/profiles/web/cordis.patch.yml. - Add the
compaction-proplugin definition. - Explicitly disable
compaction-basic.
The example configuration is as follows:
# 1) 禁用内置后端,防止冲突
- id: compaction-basic
disabled: true
# 2) 注册 dsh-compaction-pro
- id: compaction-pro
name: 'C:/Users/<you>/dsh-plugins/dsh-compaction-pro/src/index.ts'
config:
faithful: true
recursive: true
summaryLanguage: auto
thresholdRatio: 0.8
retainRatio: 0.16
maxTokens: 8192
Core Features¶
The core capabilities of dsh-compaction-pro focus on improving “summarization quality”:
- High fidelity: Enforces retention of exact values, paths, commands, and identifiers, and never rewrites them.
- Bilingual support: The summary language follows the conversation language (
automode) and supports Chinese output. - Recursive chunking: For large content segments, it first compresses chunks and then merges them, avoiding information truncation caused by the
maxTokenslimit. - Decision restoration: It not only preserves key decisions but also includes the reasoning behind them and the rejected alternatives.
- Tool result retention: A dedicated “Key tool outputs” section preserves returned structures, important return values, or file snippets.
- Custom instructions: You can replace the built-in summarization prompt entirely through the
customInstructionparameter.
Configuration Parameters¶
The plugin behavior is controlled via the YAML configuration file. The main parameters are:
| Configuration | Type | Default | Description |
|---|---|---|---|
faithful |
boolean | true |
Enables high-fidelity mode and preserves exact values. |
summaryLanguage |
string | 'auto' |
Summary language. Supports 'en', 'zh', or 'auto' (follows the conversation). |
recursive |
boolean | true |
Enables recursive chunking for processing large content segments. |
customInstruction |
string | — | Custom summarization prompt. Completely overrides the default logic. |
thresholdRatio |
number | 0.8 |
Context window ratio that triggers compaction. |
retainRatio |
number | 0.16 |
Ratio of the recent tail retained in context. |
maxTokens |
number | 8192 |
Maximum token limit for generated summaries. |
summarizationProvider / summarizationModel |
string | — | Specifies the model used for summarization. If left empty, the conversation routing model is reused. |
Notes¶
- Service conflict: This plugin and the built-in
dsh-compaction-basicshare the samectx.compactionservice interface and cannot be enabled simultaneously. You must explicitly disablecompaction-basicin the configuration file. - Early development stage: The plugin is in the
dsh v0.1.0-rc.6development stage. Upstream APIs may contain breaking changes, so pay attention to version updates. - Type definitions: Because some internal types are not officially exported, the plugin’s type definitions mirror the official internal types. If upstream contracts change, the plugin may become invalid or crash.
Summary¶
dsh-compaction-pro improves the summarization prompt to solve the problems of losing exact values and language fragmentation caused by DSH’s default compaction. By inheriting the official strategies, it achieves effective compression without distortion.
- Plugin homepage: https://github.com/helibeiqi/dsh-compaction-pro
- Directory page: https://www.skillhub.cn/plugins/helibeiqi/dsh-compaction-pro