Preface¶
The core philosophy of DeepSeek Harness (DSH) is “everything is a plugin.” During model inference, long conversation contexts can easily lead to context overflow or poor compression results, affecting inference stability. The native compression mechanism may fail in specific scenarios.
The dsh-compact-saviour plugin aims to solve this problem. It provides DSH with more reliable context compression capabilities through an independent compression model and rescue mechanism. This plugin is maintained by aa2246740, follows the MIT license, and is currently adapted to DSH version 0.2.0-rc.2 (requiring peer dependency >=0.2.0-rc.1 <0.2.1).
Core Features¶
The plugin provides the following core capabilities:
* Independent Model Auto-Compaction: Uses the configured independent model for summarization without executing tools, document instructions, or embedded prompts from the history.
* Long-Press Compaction: Long-press for 650 milliseconds on the context ring to trigger compaction.
* One-Click Manual Compaction: After configuring the model in the settings panel, you can directly click a button to execute compaction.
* Rescue Mode After Two Failures: When the official compaction fails twice consecutively, the plugin silently switches to the configured independent model for rescue.
* Chunked Compaction: Dynamically chunks based on the model’s context capacity, no longer fixed to eight chunks or limited to 32K per chunk, with support for multilingual conservative estimation.
* Preserve Original Logs: Summarization is lossy compression that may miss details, but the original conversation logs are always preserved.
Installation and Activation¶
Before installation, ensure that DeepSeek Harness >=0.2.0-rc.1 <0.2.1 is installed. The plugin does not depend on dshx, Creator Mode, Harness source code, or local builds.
Desktop Application¶
- Open DeepSeek Harness or DSH Studio, go to the Plugins page, and click Add Plugin.
- Enter the following in the Package Name or Address field and follow the official installation wizard:
dsh-compact-saviour@0.2.8
- After installation is complete, open Settings → Compact Saviour, select the compression model and reasoning level, and save.
Web Host (CLI)¶
When using the official dsh CLI:
dsh plugin --profile web add dsh-compact-saviour@0.2.8
If the dsh command is not installed globally, use npx:
npx @deepseek-ai/dsh@0.2.0-rc.2 plugin --profile web add dsh-compact-saviour@0.2.8
Release Package¶
Download the .tgz file from the v0.2.8 Release and select it in the official plugin manager.
Typical Usage¶
After installation and configuration, you can use it in the following ways:
- Configuration: Go to settings, select an independent compression model (e.g., a small-parameter model) and reasoning level, then save.
- Long-Press Compaction: Long-press for 650 milliseconds on the context ring in the conversation input bar, and the system will immediately start compaction. The ring position will display an
Open Bot Motion #7 satellitesmall robot animation, and the text inside the button will rotate every 6 seconds (e.g., “Compacting”, “Making room for the next conversation round”). - Manual Compaction: Click the ring to open the original popup, then click the Manual Compact button inside.
Auto Rescue Logic¶
The plugin defaults to the “rescue after two consecutive official failures” mode. This means the official handler runs first, and after two consecutive failures meeting the criteria, the plugin silently takes over using the configured model. Manual compaction and long-press operations always directly use the configured model without going through the official failure check.
Implementation Details and Limitations¶
Compaction Strategy¶
The plugin wraps the official BasicCompactionEngine and TokenMeter instances without modifying prototypes or core source code.
* Chunking Logic: Estimates based on the model’s context capacity, subtracting output reservations, prompt wrapping, and a 15% safety margin to calculate the number of chunks. If it can fit entirely, it calls only once; otherwise, it requests at most two chunks simultaneously and merges them.
* Budget Calculation: Combines the target conversation model, fixed prompts, and tools to calculate the summarization budget. Input length uses multilingual conservative estimation (current DSH does not provide per-model tokenizers).
* Error Handling: When encountering CONTEXT_WINDOW_EXCEEDED, shrinks the exceeded portion and continues. Each branch can be shrunk at most four times.
Performance and Boundaries¶
- Timeout Limits: A single request takes at most 2 minutes, and the entire rescue process takes at most 10 minutes.
- Log Preservation: Summarization only replaces the conversation surface seen by the model next time; the original conversation logs are preserved.
- Lossy Compression: Summarization is a lossy operation that may miss details.
Applicable Scenarios¶
- Context window is limited, requiring more aggressive compaction strategies.
- Want to perform compaction through an independent model (rather than the current conversation model) to save conversation quota.
- Need a reliable rescue mechanism to prevent conversation interruption caused by compaction failures.
Notes¶
- Summarization quality depends on model capability and budget estimation; the declared window cannot be treated as a quality guarantee.
- The plugin collaborates with other plugins through the optional public service
compactionRoutes. - After uninstalling the plugin, the native compaction logic will be restored, but already-compressed conversation states remain unchanged.
Conclusion¶
dsh-compact-saviour enhances the stability of DeepSeek Harness in long conversation scenarios by providing an independent compression model, chunking strategy, and failure rescue mechanism. For developers seeking a controllable compaction process, this is a practical supplementary tool.