dsh-compactor
Run the following command in DeepSeek Harness:
dsh plugin install lionwill/dsh-compactor
Paste the following prompt into your AI chat to install this plugin:
Run dsh plugin install lionwill/dsh-compactor in your DeepSeek Harness terminal to install this plugin; the full source repository is at https://github.com/lionwill/dsh-compactor .
About this plugin
In long DeepSeek Harness sessions, tool results — search hits, file contents, command output — routinely consume the bulk of the context window, yet only a small fraction of that material is actually useful for downstream reasoning. Repeated tool calls and verbose assistant replies keep inflating token counts and can even trigger runaway loops where the model keeps invoking the same tool with the same parameters. dsh-compactor addresses this head-on: it systematically compacts context without breaking dsh's append-only session log, so long conversations stay efficient without losing critical information.
The plugin works through three coordinated layers. In the real-time layer, tool results are pruned the moment they enter the event stream — search results keep only titles and short snippets, files keep a preview, and command output keeps the exit code and key lines. In the batch layer, after each assistant turn the session token count is estimated; once it crosses a threshold (default 32768), compressible segments are replaced with a single structured summary, with boundaries automatically aligned to tool-call / tool-result pairs and the most recent N turns never touched. The archive layer writes every displaced original to an append-only JSONL file, so /restore brings the full text back at any time. Two summarization engines are available: an API engine that calls deepseek-chat for skeleton summarization (falling back to local extractive summarization when no key is set) and a local rule-based engine triggered by /local-compact that requires zero network access and zero new dependencies. A built-in anti-loop guardrail watches the tool/call event stream, injects an anti-loop reminder after three identical calls, and records a cancellation decision after five, for the host toolRuntime to consume. Every compaction run produces a structured report listing each compressed range, per-item and overall compression ratio, before-and-after token counts, and keyword retention rate.
It is well suited for developers and research teams who lean heavily on tool calls and long-chain reasoning inside DeepSeek Harness, and for anyone who wants to keep context under control offline — the local rule engine needs no API key, no network, and no extra dependencies, and rule changes take effect on the next /local-compact run without restarting the session.
Use Cases
- Tool results (search hits, file contents, command output) dominate the context window in long sessions and need per-turn automatic compaction to keep token usage in check
- The model repeatedly invokes the same tool with identical parameters, risking infinite loops that a guardrail must detect and report
- Offline or key-free environments still need controllable context compression with full text restorable afterward
Best For
- Developers and researchers who rely on heavy tool calls and long-chain reasoning inside DeepSeek Harness
- Teams that want offline, zero-dependency context control without any network call
- Users of long sessions who care about token efficiency and need full rollback after compaction
Related Plugins
A unified suite combining hot runtime injection, task-aware thinking-mode routing, and a graded session protocol with red-team gates to sustain model diligence across long-horizon inference.
ModLens is a vision plugin for DeepSeek Harness that gives text-only models sight by reading images pasted directly into chat, with zero-config setup and multiple vision engines.
On-demand vision for text-only DeepSeek Harness agents: built-in free keyless vision chain and 14 vision tools, routing image turns as tool calls to vision models with pixel fidelity, no Python needed, one-command install.
Give text-only models in DeepSeek Harness eyes, enabling image Q&A, long-screenshot OCR, UI restoration, and GUI visual tasks.