AI Agent Hub
Back to plugins
🤖

dsh-token-saver

Model Inference Updated 2026.09.02

Run the following command in DeepSeek Harness:

dsh plugin install Shaw529/dsh-token-saver

Paste the following prompt into your AI chat to install this plugin:

Run dsh plugin install Shaw529/dsh-token-saver in your DeepSeek Harness terminal to install; the full source is available at https://github.com/Shaw529/dsh-token-saver

About this plugin

Anyone who has run a long DeepSeek Harness task has probably hit the same wall: a single read of a 600k-line migration script, or a grep that matches across dozens of files, can dump over a million tokens into the prompt while the model never finishes reading them. dsh-token-saver is a Cordis plugin built exactly for that scenario. It targets tool-return results, applying lossless head-tail trimming and grep collapsing to shrink the characters sent to the model to a few percent of the original, while the full pre-folding content remains intact in the session log for replay and reconstruction.

Four modes (off, conservative, balanced, aggressive) let you dial in the trade-off. The default conservative mode replaces only the middle segment with a one-line metadata marker, keeps head and tail fully intact, and never touches the native dsh compaction pipeline, so task reasoning is untouched. Balanced tightens the head-tail budget and delegates pressure-windowing to the official ctx.compaction hook. Aggressive additionally takes over dsh-compaction-basic and optionally plugs in an LLM-summary engine. Every rewrite flows through the dsh event stream; waterfall listeners always await next() first, error results and tiny payloads auto-pass through, and no private field is ever mutated, so deriveMessages() stays consistent at any snapshot point.

It is built for developers running multi-step dsh agent tasks, frequently reading large files or executing heavy greps, and watching token spend without wanting to sacrifice output quality. Across eight realistic benchmark scenarios the combined token count dropped from 3.83 million to 90,729 (conservative, 97.6 percent saved) or 56,923 (balanced, 98.5 percent saved). Install it and it activates immediately with no changes to your existing workflow.

Use Cases

  • A single read of a large file during a long task inflates prompt tokens
  • Grep matches across dozens of files flood the context window with results
  • Cumulative tool-result overhead in multi-step agent sessions drives up token spend

Best For

  • Developers running multi-step dsh agent tasks
  • Teams that need to control LLM API costs
  • Users whose workflows frequently read large files or run heavy greps