Preface¶
DeepSeek Harness has built-in compression strategies, but the default values are often hardcoded (e.g., 80% of the current model’s context window). Developers sometimes require more flexible control, such as setting an absolute token limit or defining a custom ratio. dsh-context-compressor is an external plugin that provides these configuration capabilities.
Core Features¶
- Absolute User-defined Context Limit: You can set a specific token count as the session limit.
- Automatic Session Compression: Once the session reaches the configured threshold, the plugin automatically triggers compression.
- Standalone Settings Page: The plugin includes its own settings interface, eliminating the need to modify configuration files.
- Tool Result Pruning: Deterministic pruning is performed before compression as a lightweight measure.
- Pre-step Hook Integration: Detection and processing occur at every step boundary.
Installation¶
Before installation, ensure your environment meets the requirements. Use the official installation command:
dsh plugin --profile desktop add https://github.com/AllShadowAnan/dsh-context-compressor/releases/download/v1.1.0/dsh-context-compressor-1.1.0.tgz
If installing via a local link, you must run pnpm install first, as symlinks do not automatically install dependencies.
After installation, the active profile requires a browser refresh or an application restart to take effect.
Configuration & Usage¶
The plugin features a standalone settings page. You can choose between two trigger modes:
- Absolute Limit: Set a specific token count. This is suitable for controlling cost and latency ceilings.
- Window Ratio: Set a percentage of the model’s context window (e.g., 80%). This is suitable for scenarios requiring custom relative thresholds.
The settings page contains the following main options:
- Enable Trigger: The master switch.
- Trigger Mode: Absolute limit or Window ratio.
- Context Limit: Effective in Absolute mode; set to 0 for no limit.
- Trigger Ratio: Effective in Ratio mode; range is 5–95.
- Keep Last: The length of the original text tail to retain for summarization.
- Max Compressions per Step: The maximum number of compression rounds within a single step.
You can check the plugin status using the following command:
curl http://127.0.0.1:19387/dsh-context-compressor/status
Notes¶
- Token Count is an Estimate: The meter uses a fixed-density heuristic to price request mirrors. Treat trigger thresholds as budget lines rather than precise counts.
- Ratio Mode Relies on Model Declaration: If the model does not declare a context window, ratio mode will remain inactive.
- Profile with Compression Stack Required: Desktop and web profiles usually meet this, but minimal profiles may not be supported.
- pnpm Required for Local Installation: When installing via
link:, you must runpnpm install. - Restart Required After Source Modification: You must restart the application for changes to plugin source code to take effect.
References¶
- Plugin Directory: https://www.skillhub.cn/plugins/AllShadowAnan/dsh-context-compressor
- Source Repository: https://github.com/AllShadowAnan/dsh-context-compressor