Intro¶
The operation of DeepSeek Harness (DSH) relies on the context window. As conversation turns increase or tool calls become frequent, historical messages can easily fill the context, causing request failures or making the model forget early instructions. The dsh-compact plugin addresses this issue by automatically compressing historical content, providing a manual compression entry point, and implementing an overflow recovery mechanism, enabling long conversations to continue.
Plugin Overview¶
- Name: dsh-compact
- Core Value: A DeepSeek Harness plugin for automatic context compression, manual compression, and overflow recovery
- Maintainer: zixin947
- License: MIT
Installation and Activation¶
Completely exit the running DSH service, then run the following command to install the plugin:
dsh plugin --profile web add "github:zixin947/dsh-compact#main"
After installation, restart the DSH Web service. The default mount configuration is provided by cordis.patch.yml:
- id: compact
name: 'dsh-compact'
Configuration Options¶
The plugin provides the following configuration options, allowing you to control when compression is triggered, the retention ratio, and the overflow recovery strategy. The default values are as follows:
| Option | Default Value | Description |
|---|---|---|
enabled |
true |
Whether to enable automatic compression and overflow recovery |
thresholdRatio |
0.75 |
Trigger automatic compression when context usage reaches 75% of the window |
retainRatio |
0.20 |
Retain approximately the most recent 20% of the context after compression |
recoverOnOverflow |
true |
Whether to attempt recovery when a context overflow error is encountered |
maxOverflowRetries |
1 |
Maximum number of overflow recovery retries |
modelPolicies |
[] |
Override policies for specific models |
Parameter Constraints¶
thresholdRatiomust be between0.50and0.95.retainRatiomust be between0.05and0.50.retainRatiomust be less thanthresholdRatio.modelPoliciesmatches exactly usingproviderandmodel.
Configuration Example¶
- id: compact
name: 'dsh-compact'
config:
enabled: true
thresholdRatio: 0.75
retainRatio: 0.20
recoverOnOverflow: true
maxOverflowRetries: 1
modelPolicies:
- provider: youchu
model: deepseek-v4-flash
thresholdRatio: 0.80
retainRatio: 0.20
Usage¶
Basic Mount¶
General users only need to mount dsh-compact to obtain automatic compression and overflow recovery capabilities.
Agent-Level Mount¶
If the target Agent preset requires an independent compression entry point (such as the /compact command) or needs tool result pruning, mount dsh-compact/agent in the corresponding combination:
- id: compact-agent
name: 'dsh-compact/agent'
isolate:
compaction: true
toolResultPruner: true
This mount point combines the compression engine, the /compact command, and the tool result pruner.
Entry Points¶
- Automatic compression: Automatically triggered before a normal request begins, based on the context usage ratio.
- Manual compression: Manually triggered via the
/compactcommand or the entry point in the settings page.
Working Mechanism¶
Automatic Compression Flow¶
Before each Agent request begins, the plugin checks the current context usage ratio. When the ratio reaches thresholdRatio:
- Select an earlier conversation interval to compress.
- Generate a structured checkpoint summary using the current session’s model.
- Replace the original interval with a persisted summary (retaining the most recent portion of context).
- Continue executing the original request.
Each pressure check generates at most one summary to avoid repeated compression within the same turn.
Overflow Recovery¶
When the model returns a context window limit error, the plugin attempts to compress the current session and retries the original request. Recovery attempts are limited by maxOverflowRetries, and requests being cancelled are not retried.
Empty Summary Fallback¶
If the summary model returns empty text, the plugin removes the Agent system prompt and tool definitions, then performs a fallback retry once. Other network or model errors do not trigger this fallback logic.
Notes¶
- File safety: The plugin only processes DSH session context and does not delete workspace files.
- Summary quality: Compression replaces the displayed content of earlier conversations with a summary; summary quality depends on the model currently in use.
- Fault tolerance: If automatic compression fails, the plugin records the status and continues the user request; it will not interrupt the current turn due to an abnormal summary service.
- Version dependency: This version is intended for
@deepseek-ai/dsh 0.1.0-rc.7and versions with the same plugin API. - Repository independence: The standalone repository only contains the plugin itself; EAC preset migration and desktop host integration are still maintained by the EAC main project.
Summary¶
dsh-compact reduces the complexity of maintaining long conversations by automatically generating summaries when context usage approaches the limit or by performing bounded recovery when overflow occurs. For Agent scenarios that require long-running sessions or frequent tool calls, this plugin is a practical tool for maintaining conversation coherence.
- GitHub repository: github.com/zixin947/dsh-compact
- Plugin directory: skillhub.cn/plugins/zixin947/dsh-compact