dsh-live-compact: A Compress-As-You-Go Context Plugin for DeepSeek Harness
tranquillitatis-lab/dsh-live-compact
Live Compact is a DSH plugin that compacts in place as you work: each finished turn is cut without calling a model and without touching the prefix cache, keeping context low and cutting compaction cost.
dsh-live-compact is a context compaction plugin for DeepSeek Harness that swaps the usual compress-at-80%-full behavior for cutting the just-finished turn at a token threshold during each wrap-up. It never calls a model and leaves everything before the cut untouched, so cloud prefix cache hits hold at their previous level, context stays at a lower position, and the slow billable compression can be postponed as long as possible. It also distinguishes cloud from local endpoints, uses the newest card as a floor for the cut point, and writes per-cut details to a record file.
How to Install
dsh plugin --profile web add github:tranquillitatis-lab/dsh-live-compactReplace --profile with the profile name you actually run (see ls ~/.dsh/profiles/): usually web in the browser UI, desktop or desktop-NNN in the desktop app.
- Category
- Memory & Context
- Platform
- DSH Plugin
- Author
- tranquillitatis-lab
- Distribution
- Plugin
dsh-live-compact Key Features
dsh-live-compact Repo Summary
What Does It Do?
Live Compact is a DSH plugin for DeepSeek Harness that replaces the default "compress only when the window is about 80% full" behavior with continuous, in-place compaction. It solves the problems of that default: context sits at a high level for a long time, the eventual compression calls a model and takes over ten seconds plus billing, attention drifts afterward, and the window fills up again soon. The plugin cuts the turn that just finished once a token threshold is crossed, without calling a model, and leaves everything before the cut untouched, so prefix cache hits stay at their previous level and context is held at a lower position while the big compression is postponed as long as possible.
Core Features
- Compress as you go: cuts the just-finished turn at a token threshold without invoking a model, avoiding the slow, billable compression that only fires when the window is full.
- Preserve the prefix cache: text before the cut is never rewritten, so cached prefixes keep their original hit rate on cloud providers.
- Cloud and local awareness: distinguishes cloud (public) endpoints from local (loopback, intranet) ones by configured address, with an environment variable to force the engine; local setups are not judged by cloud cache-hit numbers.
- Card floor protection: treats the newest card as a floor for the cut point, stopping when it reaches a card and skipping the cut when newer cards sit to its right, so the next turn's input is not pushed back to 200K+ tokens.
- Accurate accounting: multiple cuts in one wrap-up are counted once for rewrite volume, with per-cut details written to a shadow-directory record containing only sequence numbers, tokens, and cut points, never message text.
- Tunable thresholds: the official compression ratio, headroom, and retention values can be overridden by environment variables before startup, with defaults unchanged.
How to Use This Plugin?
After enabling it in DSH, no extra action is needed: the plugin evaluates each turn wrap-up and cuts the just-finished turn once the threshold is crossed. On cloud setups, just install it and leave the thunder-related environment variable unset, then check whether answers are correct and what the cache hit rate is at each turn's first step_end. On local setups it also works, but do not hold it to cloud cache-hit expectations; watch answer correctness and how many tokens were cut instead, since local servers have no cloud-style prefix cache and re-prefill the current context on every request. Use the stats subcommand to read rewrite volume and other counters, and edit the corresponding fields in the current configuration to adjust the big-compression parameters, since the TUI settings screen does not expose them.
How to Troubleshoot This Plugin?
- A local setup shows only about 20K tokens and looks like nothing was cut: that number is the current context size, not a sign the plugin failed; on local setups watch cut tokens rather than cache hits.
- The next turn's input jumps back to 200K+ and the prefix is lost: the cut point moved left of an existing card; follow the official guidance to a version that treats the newest card as a floor.
- The desktop app hangs for a long time: older versions copied the whole session log and re-measured on every turn and every tool result; follow the official guidance to a version that copies the log once per idle turn.
- Every local request sends less prefix than expected: check whether thunder mode was enabled with the 27b model; do not enable it on local setups.
This page is an independent rewrite of the plugin's official README — for authoritative documentation and the latest changes, refer to the source: tranquillitatis-lab/dsh-live-compact. The plugin is third-party code that runs on your machine once installed; inclusion does not imply endorsement — please review the source before installing.
DSH Plugin FAQ
