Introduction¶
DeepSeek Harness (DSH) automatically condenses earlier history when conversations grow longer, trading context space for summaries. For models with context windows significantly smaller than approximately 330k tokens, the built-in strategy often triggers compression when the on-screen context ring still appears “half-empty.” Furthermore, it may trigger again within a few steps after compression, leading to repeated compression cycles.
Modifying configuration files usually doesn’t help: in DSH 0.2, the compaction strategy is embedded within each agent preset. Since presets are defined as entire packages, modifying a single field either isn’t possible or requires replacing the whole package and locking the preset, preventing it from keeping up with DSH updates. dsh-compaction-policy, published by community maintainer zyd232, falls under the “Memory” category of capabilities. It does not modify on-disk configurations; instead, it adjusts the trigger conditions of the compaction engine at runtime within DSH, with settings configurable per provider or model.
What is this¶
dsh-compaction-policy is a DSH plugin whose core function is to delay “premature” automatic context compaction and place the threshold for “when to start compacting” under your control via adjustable parameters (the default remains close to DSH’s habitual 80% window usage). It only changes when compaction is triggered; the amount of history retained after compaction and how summaries are written are still determined by DSH’s native compaction backend. Emergency recovery (handling after requests are rejected due to length) and manual /compact are unaffected.
- Maintainer: zyd232
- Community Directory: SkillHub Plugin Page
- Source Code & Docs: GitHub — zyd232/dsh-compaction-policy
- Current Package Version:
0.1.2(subject to repository)
The DSH ecosystem emphasizes “everything is a plugin”; directories like SkillHub are community sites and have no official affiliation with DeepSeek or High-Flyer.
Why the built-in strategy compacts “early”¶
Before every step’s request, DSH estimates the token count of the next request and compares it against the following trigger line:
trigger = min(window × 0.8, window − output reserve − 65536)
Here, window is the model context length known to DSH, output reserve is the tokens reserved for the model’s reply, and 65536 is a fixed safety margin retained by DSH. When the window is small, subtracting the fixed 65536 is often tighter than “80% of the window,” meaning the actual trigger point will be far below 80%. The README provides the following comparison examples (specific values subject to official documentation):
| Context window | DSH Actual Trigger ~ | 80% ~ |
|---|---|---|
| 128k | ~62k (49%) | 102k |
| 150k | ~84k (56%) | 120k |
| 256k | ~190k (74%) | 205k |
| 1M | ~678k (68%) | 800k |
If you primarily use ultra-large windows around the 1M level, the built-in behavior is already close to 80%, and installing this plugin is generally unnecessary.
Core Features¶
The plugin wraps the compaction service logic of each agent preset at runtime. The behavioral key points are as follows:
- When context usage is below your configured trigger line, the plugin directly returns “no compaction needed,” preventing DSH’s native pre-check from acting prematurely based on the old formula.
- When reaching or exceeding the trigger line, the decision is handed back to DSH, consistent with behavior without the plugin installed.
- If the plugin encounters internal errors, it automatically yields, ensuring session behavior remains identical to when it is not installed, avoiding disruption to the session.
- A Compaction policy panel is added to the Settings sidebar (including Chinese, depending on DSH language settings). Changes take effect immediately without requiring a restart; each item can be restored to default.
Installation and Activation¶
The installation command must use the profile you are actually running (e.g., desktop for the desktop app, web for dsh web, or your custom profile name). You must restart DSH after installation—the plugin list is only loaded at startup. You do not need to start a new conversation; it will take effect on the next step of existing conversations.
dsh plugin --profile <your profile> add github:zyd232/dsh-compaction-policy
Uninstallation:
dsh plugin --profile <your profile> remove dsh-compaction-policy
Version Notes (excerpt from README): Verified on DSH 0.2.1-rc.2; dsh.verifiedWith in package.json is also this version, with a compatibility declaration of >=0.2.0-rc.2. DSH versions earlier than 0.2.0-rc.2 are not supported (per-preset compaction engine was introduced in 0.2). If the plugin has no effect on your current version, this is a designed degradation behavior rather than a crash; you can report it to the repository issues with the output of dsh --version.
To determine if it loaded successfully: look for the compaction policy entry in Settings; the actual context ring should be able to pass the previous “drops when half-full” point, and the request usage at the time of compaction should be close to your set Trigger ratio.
Typical Usage and Configuration¶
Open Settings and find Compaction policy on the left. The main fields are as follows:
| Field | Default Value | Meaning |
|---|---|---|
| Enable | on | If disabled, restores DSH’s native compaction behavior |
| Routes | * |
Applicable routes: provider or provider/model, separated by commas or spaces; * means all |
| Trigger ratio | 0.8 |
Triggers compaction when reaching this ratio of the window (0.8 is 80%) |
| Output reserve (tokens) | 24576 |
Tokens reserved for model replies; DSH’s built-in is 65536. Lowering this is key to mitigating “premature triggering” |
Selection suggestions (from README):
- Trigger ratio: Generally keep at
0.8; try0.7for extra margin on extremely small windows. - Output reserve: Set to “the longest reply you realistically expect + a small amount of slack”;
16384–32768is usually sufficient for common chat and coding. Increase appropriately if writing ultra-long files; too small may result in replies having nowhere to go and requests being rejected. - Routes: Can be narrowed to apply only to specific providers, e.g.,
llama-cpp,ollama,openai, orollama/*to cover all models under that provider.
With the default reserve of 24576, for models with windows larger than approximately 123k, the trigger line can stably land near 80% of the window.
Verify it works according to the new policy: check the compaction records in the session log; or estimate (“request tokens ÷ model window”) just before compaction, which should be close to your ratio rather than the old ~50% range.
Use Cases and Notes¶
Who is it for
- Local or small-context hosted models (windows significantly smaller than ~330k tokens).
- Context rings that get compacted when they “look empty,” and where compaction happens repeatedly within a few steps.
Limitations and Risks
- Only moves the trigger point; does not customize summary content or retention policies.
- If the window is too small to even fit the system prompt and tool schema, DSH wouldn’t configure active compaction anyway, and the plugin does not forcibly intervene.
- The implementation relies on internal DSH APIs (such as
agentPresets.serviceFor(…, 'compaction')andcompactIfNeeded); if DSH changes interfaces in the future, the plugin may temporarily fail until updated. - The plugin runs under the permissions of the current dsh process. Before installation, please review the GitHub source code and the license (
LICENSE) in the repository yourself to decide whether to use it in production environments.
Conclusion¶
If your main pain point is “DSH compacts conversations into summaries too early” rather than “summaries are written poorly,” dsh-compaction-policy provides a runtime path that doesn’t lock presets or modify global configuration files: adjust the trigger ratio and output reserve by route, bringing the timing of compaction back to the window usage you expect.
- Directory Page: https://www.skillhub.cn/plugins/zyd232/dsh-compaction-policy
- GitHub: https://github.com/zyd232/dsh-compaction-policy