AI Agent Hub
Back to plugins
🤖

dsh-token-optimizer

Model Inference Updated 2026.09.16

Run the following command in DeepSeek Harness:

dsh plugin install Zoria-Lind/dsh-token-optimizer

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

Run dsh plugin install Zoria-Lind/dsh-token-optimizer in your DeepSeek Harness session to install this plugin; the source repository is available at https://github.com/Zoria-Lind/dsh-token-optimizer .

About this plugin

In long conversations, verbose tool outputs, repeated file reads, and unused MCP tool schemas continuously bloat the context window, while DSH's built-in compaction threshold of 0.8 rarely fires on million-token windows. dsh-token-optimizer fills exactly that gap: rather than reimplementing what DSH already ships, it inserts a layered pipeline that compresses, trims, and samples text before it ever reaches the model.

The pipeline touches six points. text2img renders passages of 1,000+ characters into images and lets a vision model produce a summary (a single sample saved roughly 72 percent, and subsequent turns no longer carry the original text). outputLadder performs a single-pass triage at the tool-output source: errors become short summaries, JSON arrays and CSV files get structure-aware compression, and shell output keeps its head and tail with equidistant sampling in between. fileDiff collapses repeated reads of unchanged files and sends only changed regions when content shifts. toolTrim lazy-loads MCP tool schemas so unused ones never enter the request (measured saving of about 9,400 tokens per call). compactionDriver proactively triggers the core compactNow at a 45 percent pressure ratio when the agent is idle, compensating for the near-zero trigger rate on large windows. monitor reports session-end savings and real cache-hit rates (typically 97 to 99.3 percent).

If you run multi-turn deep sessions, have MCP servers mounted, or deal with tool outputs that routinely exceed tens of thousands of characters, this plugin meaningfully cuts token overhead without sacrificing model capability. Every module follows a fail-open policy: any error degrades to keeping the original text and never blocks DSH's core flow.

Use Cases

  • Tool outputs and repeated file reads inflate token cost in long conversations
  • Heavy MCP mounts waste request space with unused tool schemas
  • Built-in compaction barely triggers on large windows, making long sessions increasingly expensive

Best For

  • Developers running multi-turn deep conversations frequently
  • Users managing tool visibility across multiple MCP servers
  • Teams sensitive to token costs and API billing