- Home
- Plugins
- Tools & Capabilities
- dsh-token-squeeze
dsh-token-squeeze
mutao106/dsh-token-squeeze
Squeezes every tool result before the model reads it, stripping terminal noise, folding JSON and console tables into compact records, capping oversized output with an on-disk spill and collapsing repeated results.
Install
dsh plugin --profile web add github:mutao106/dsh-token-squeezeREADME
dsh-token-squeeze
Lossless-first tool-output compression for DeepSeek Harness.
Every tool result the model is about to read goes through one pass:
| Step | What it does | Loses content? |
|---|---|---|
| denoise | strips ANSI/OSC terminal escapes, collapses blank-line runs, folds long runs of an identical line into [… previous line repeated N more times] | no |
| reshape | JSONL → compact record table, whitespace-heavy JSON → minified, aligned console tables → head/tail/omitted-rows table | yes, bounded |
| budget | caps one result at budgetChars, keeping the head and the tail with an explicit N lines / M chars omitted marker | yes, bounded |
| dedupe | a byte-identical result already returned earlier in the same session (same tool, same arguments) collapses to a one-line pointer at that earlier call | yes, by design |
Anything a lossy step drops is written to disk first (the spill), and the notice line in the compressed result carries the absolute path, so the model — or you — can read the original back at any time.
Two invariants hold on every call:
- Never worse. Content is only replaced when the new text is strictly
shorter, and a lossy step must save at least
minSavingCharson its own. - Programs are untouched. The hook only rewrites model-facing
content, never the programmaticvalueof a tool call, so PTC programs still see exact data.
Install
From GitHub — clone, then point dsh at the checkout:
git clone https://github.com/MuTao106/dsh-token-squeeze.git
dsh plugin add ./dsh-token-squeeze
From a local bundle (recommended if you already have the directory):
dsh plugin add E:\path\to\dsh-token-squeeze
or ask the agent to run plugin_manager with action install_bundle and the
absolute package directory. The bundle's cordis.patch.yml inserts one plugin
row with the defaults below; override any key by id: token-squeeze in a later
profile patch layer.
Manual install: add the package to the profile's packages/ directory, then add
"dsh-token-squeeze": "link:packages/dsh-token-squeeze" to the profile
package.json dependencies and re-run the profile install. Do not hand-edit
cordis.patch.yml — use a patch layer.
Configuration
| Key | Default | Meaning |
|---|---|---|
enabled | true | master switch |
denoise | true | escapes, blank runs, repeated lines |
reshape | true | JSON/JSONL/aligned-table compaction |
budget | true | apply the character cap |
budgetChars | 16000 | per-result cap; 0 disables |
errorBudgetChars | 12000 | floor for failed results, so errors stay readable |
minSavingChars | 800 | a lossy step must save this much to apply |
minChars | 200 | ignore results shorter than this |
skipTools | ["write","edit"] | never rewrite these tools |
dedupe | true | collapse repeated results |
dedupeTtlMs | 600000 | how long a fingerprint stays live |
dedupeMinChars | 400 | only dedupe results at least this long |
spill | true | persist the original before dropping content |
spillDir | "" | empty means ~/.dsh/token-squeeze/spill |
spillMaxBytes | 4000000 | never spill originals larger than this |
notice | true | prefix the one-line savings notice |
verbose | false | log every rewrite to the plugin logger |
A conservative profile for code-heavy work:
- id: token-squeeze
config:
budgetChars: 24000
minSavingChars: 2000
skipTools: ["write", "edit", "read"]
read results are already file-backed, so skipping them keeps exact source
lines in front of the model.
Relationship to the built-in plugins
dsh-token-squeeze deliberately covers ground the stock plugins do not:
@deepseek-ai/dsh-spill-policyspills and truncates large results, but does not denoise, reshape, or deduplicate.@deepseek-ai/dsh-compaction-tool-result-prunerprunes tool results later, at theSessionlayer. Running both is fine; the pruner then only sees text this plugin already shrank.dsh-plugin-save-token(third-party) overlaps on blank-line and repeated-line collapse and on cross-turn dedupe. Running both double-rewrites the same result and doubles the notices — keep one of them enabled.
Cost model
No model calls, no network, no timers. The pass is pure string work plus, only
when a lossy rewrite actually applies, one writeFile of the original. The
estimate in notices counts CJK characters as one token and everything else at
four characters per token.
Development
node --test # the compressor's unit tests, no DSH needed
lib/compress.js is dependency-free and usable on its own:
import { squeezeText } from 'dsh-token-squeeze/compress'
const { text, steps, before, after, lossy } = squeezeText(raw, { budgetChars: 8000 })
Related plugins
archify (deepseek-harness)
tt-a1i/archify
WeKnora (dsh-weknora)
tencent/weknora
next-ai-draw-io (dsh-plugin)
dayuanjiang/next-ai-draw-io
AiToEarn (dsh-plugin-aitoearn)
yikart/aitoearn