DSH Hub

unclecode/toolshrink

toolshrink

BundleWorkflow10 GitHub stars· updated 2026-08-19

Cut large agent tool output by what it means, not by where it was cut. 13 content-aware reducers + DeepSeek Harness plugin.

Install

npx @deepseek-ai/dsh plugin --profile web add github:unclecode/toolshrink

Restart `dsh web` after install. Bundle APIs can change during the developer preview.

README badge

toolshrink DSH Hub badge
[![DSH Hub](https://dshhub.dev/badge/toolshrink.svg)](https://dshhub.dev/plugins/toolshrink)

Paste this into your README. The star count updates with every catalog sync.

From the README

Excerpt from unclecode/toolshrink, cleaned of badges and images.

toolshrink

Cut large agent tool output by what it means, not by where it was cut.

I use Claude Code every day, and I always wanted to intervene in how it manages context. In the early days you could edit the session JSONL directly. Then that door closed.

When DeepSeek open-sourced Harness, where everything is a plugin, I looked inside. Tool output there is cut by size: keep the head, keep the tail, drop the middle. I read Codex and pi, and they do the same. None of them look at what the text contains.

That fails in a predictable way. Your test suite prints 5,000 passing lines and 3 failures in the middle. A size cut keeps the passes and throws away the failures. The model reads it, believes the run, and answers wrong.

So I built the shrinker I always wished Claude Code had. It reads the output first, recognizes its shape, and keeps the part that carries the information:

input: a vitest run, 31,958 chars, 805 lines, budget 2,000 chars

head+tail cut:   1,904 chars   the model learns: the summary
toolshrink:        255 chars   the model learns: which test failed,
                               why, at which line, and the summary

Everything removed is counted in a marker the model can read, and the complete original is saved to disk with a locator. Nothing is lost silently.

The cuts

Each cut recognizes one shape of text. The first one that recognizes the input runs. When none does, the size fallback runs, so the result always fits the budget.

CutRecognizesKeepsDrops
diffgit diff, patcheschanged lines, file and hunk headers, 1 context line each sideunchanged context
jsonone JSON valuethe structure, 3 samples per long array, 5 keys per wide object, countsrepeated records
testsvitest, jest, pytest, cargo test, go testfailures with their explanation, the summarypassing tests
buildtsc, cargo, gcc, webpack, esbuilderrors and warnings with their code frame, the summarybuild progress
stacktracenode, Python, Java, Ruby tracesthe message and frames in YOUR codedependency frames, counted
logtimestamped logserrors and warnings with the lines before them, the endingroutine lines
treefind, ls -R, file listingsthe structure, 8 entries per directory, countscrowded directories
repeatretry storms, progress spam2 samples per run plus "2,998 similar lines omitted"consecutive near-identical lines
linteslint, ruff, clippyeach rule with its count and example locations, worst filesrepeated occurrences of the same rule
installnpm, pip, pnpm, cargothe summary, versions, deprecations, vulnerabilities, errorsfetch and download progress
csvCSV, TSV, pipe tablesheader, 5 rows from the start, 2 from the end, row and column countsthe rows between
gitloggit log, both formatsthe 15 newest commits, the total, the authors with countsolder commits
sizeeverything (fallback)bash: the end · grep/read: the start · unknown: both endsthe rest, counted

Thirteen cuts ship today. Each one is a plain file with a shared interface, so adding your own is one file, not a fork.

Every cut follows four rules, taken from the three agents I read:

Related plugins