DeepSeek Harness plugin that trims tool output (head/tail plus grep folding), adds optional prompt shaping (Caveman and Ponytail), instant local responses, RTK command-output compaction, context-pressure handling, optional LLM-summary compaction, stable prompt-cache layout, a Web settings UI, and persisted savings telemetry.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:LoveDoLove/dsh-token-saver
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
Keep more of your context window for the model. A DeepSeek Harness plugin that trims oversized tool output, folds grep results, and makes prompt shaping and local answers optional.
简体中文 · Documentation · Releases · Issues
Why
Tool output fills a context window faster than anything else. One file read, one
grep, or one build log can add tens of thousands of bytes the model never
needed, and those bytes stay in the conversation for every later turn.
Token Saver works at the DSH tool-execution boundary. It keeps the head and tail of long results, folds search output down to its matches, and can apply shape-aware RTK filters. It never touches user messages, assistant messages, or errors, and it fails open: a compaction error returns the original result.
Features
| Feature | What it does | Default |
|---|---|---|
| Tool-output trimming | Keeps the head and tail of oversized results | On |
| Grep folding | Keeps matches plus context | On |
| RTK filters | Shape-aware compaction for diffs, logs, trees, tables | Off |
| Caveman shaping | Terse, direct answers with exact code and paths | Off |
| Ponytail shaping | Minimal-change, smallest-diff style | Off |
| Local responses | Answers quota, prefix, title, suggestion, filepath probes | Off |
| Context pressure | Triggers compaction above a threshold | Off |
| Web panel | Settings and savings in Settings → Token Saver | On DSH Web |
Every feature can be turned off. mode: off disables all tool-output
compaction; prompt shaping and local responses have their own switches.
Quick start
dsh plugin --profile web add github:LoveDoLove/dsh-token-saver
Pin the current release:
dsh plugin --profile web add github:LoveDoLove/dsh-token-saver#v1.0.7
If DSH asks for build-script approval, follow the printed instructions and retry.
The prebuilt dsh-token-saver-1.0.7.tgz on the
v1.0.7 release
installs without a local build.
Upgrading from v1.0.4 or older? v1.0.5 fixes a data-destruction bug in RTK autodetection that could collapse README-style prose. Upgrade if you read files through a tool.
Configuration
Configuration lives in the bundle row in your DSH profile. A typical setup:
- id: dsh-token-saver
name: dsh-token-saver
config:
mode: conservative
headBytes: 16384
tailBytes: 8192
rtkEnabled: false
cavemanLevel: off
ponytailLevel: off
localResponsesEnabled: false
| Mode | Behavior |
|---|---|
off |
No trimming, folding, or RTK |
conservative |
Trim and fold only; never compacts the session |
balanced |
Adds pressure-driven compaction when enabled |
aggressive |
Same as balanced, with a lower bar for compaction |
The Web panel writes live overrides to $DSH_HOME/token-saver/settings.json.
See configuration for all 22 options.
How it works
tools/post-execute— decide whether a result should be compacted. Errors and structured values pass through.- Strategy — RTK filter, grep fold, or byte-budget truncation, whichever fits the tool and the result.
ctx.systemPrompt.section()— add Caveman or Ponytail text as a prompt section. The frozen LLM request is never rewritten.llm/stream— answer a recognized probe locally with zero usage; otherwise pass through.
Safety
- Errors are never compacted.
- Output is accepted only when it is non-empty and strictly smaller.
- Every strategy fails open.
- Prompt text uses the supported section API, not the assembly waterfall.
- The agent-loop LLM request is never mutated.
- Invalid configuration fails activation instead of being silently coerced.
Benchmark
UTF-8 bytes on synthetic fixtures:
| Fixture | Before | After | Saved |
|---|---|---|---|
| Large diff | 182,892 | 24,675 | 86.5% |
| Grep result | 29,321 | 8,145 | 72.2% |
| Find result | 29,321 | 12,321 | 58.0% |
| Build log | 19,781 | 1,301 | 93.4% |
| Table | 9,423 | 2,163 | 77.0% |
Bytes are not tokens. Method: benchmark-methodology.
Documentation
- Whitepaper · 白皮书
- Architecture
- Configuration
- Tool-output compression
- Prompt shaping
- Local responses
- Statistics
- Compatibility
- Development
Compatibility
Targets DSH >=0.2.0 <0.3.0 and Node >=22.19.0. Works alongside Billion
Context, OmniRoute, and Our Free Model. Details:
compatibility.
Development
pnpm install
pnpm prepack
pnpm prepack runs lint, typecheck, tests, build, and package verification.
Agent guidance: AGENTS.md.
License
MIT
Links
More in this category
bowenliang123/dsh-context★ 5632
DeepSeek Harness officially recommended - a context insight plugin for context composition, evolution and Multi-Agent collaboration. It provides a cross-session Insights page (tokens, cost, cache hit, activity heatmap, skill and tool loads), a per-session Context tab (composition, token and timing stats, timeline, browser, events, file activity, command executions), a Fleet tab for the agent family (the current agent, its parents and every subagent), and a /context command.
Han-1413141/dsh-cost-meter★ 791
Per-session and daily API cost, budget with usage %, official balance, history dashboard, and one-click official price sync with peak/off-peak pricing.
wssfk12138/dsh-damage-pulse★ 292
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 207
Sidebar usage panel that attributes tokens to the relay site that served each request, read from your existing provider config: today/month/all-time totals, per-site and per-model breakdowns, a year activity heatmap, and New API / Sub2API / DeepSeek balances.
Ychris12138/dsh-usage-stats★ 195
Multi-provider usage dashboard with provider/model token breakdowns, calendar drill-downs, account balances, and OpenCode Go / Z.ai subscription quota tracking.
Mt-Youya/dsh-plugins#sessions-insight★ 132
Browse Claude Code, DSH and Codex session logs by working directory, with per-turn context composition, token usage, compaction markers and cost estimates.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.