DeepSeek Harness Plugin

ium9khbep8834-maker/dsh-cache-saver

Stars ★ 0 Category Usage & Billing Added 2026-10-20

Slims oversized MCP tool JSON Schemas per agent without changing dispatch, and reports token usage, cache hits and context composition on a settings page.

Install

# from a prebuilt release tarball

dsh plugin --profile web add -w "https://github.com/ium9khbep8834-maker/dsh-cache-saver/releases/download/v0.3.1/local-dsh-cache-saver-0.3.1.tgz"

# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)

dsh plugin --profile web add github:ium9khbep8834-maker/dsh-cache-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

English · 简体中文

A host + client bundle for DeepSeek Harness. Every request re-sends the whole prompt prefix — tool JSON Schemas included. This plugin shrinks the oversized ones (dispatch untouched) and then shows you where the re-sent context goes, in a settings page.

Measured on a real profile — a fresh session's first request:

tools prompt tokens
plugin off 269 270,767
plugin on 270 69,559 (−74.3 %)

Same tools, same calls. Only the manual got smaller.

Install

Close DeepSeek Harness first (it holds the desktop profile), then one command:

"<install dir>\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:ium9khbep8834-maker/dsh-cache-saver

Or with npm — one command, then add "@local/dsh-cache-saver" to dsh.profile.bundles in ~/.dsh/profiles/desktop/package.json (npm cannot know about DSH bundles):

npm install github:ium9khbep8834-maker/dsh-cache-saver

Restart (or reload the page) once — the client half is imported at boot — then open Settings → Cache saver. Other profiles: same command with --profile web / --profile dsh-tui (plain dsh, no .cmd).

What it does

1. Schema slimming — the same tools, a smaller manual

On a fresh agent the plugin copies each tool definition into that agent's scope and replaces only description / parameters. execute, output.render, timeout and safety flags are inherited, so dispatch is unchanged; DeepSeek Harness does not validate arguments (the MCP server still does), so nothing is rejected. Eight frequently used rea tools are on a keepFull allowlist.

Typical result with the default config: 158 tools, 740,692 → 121,190 chars (−83.6 %), with the five monster schemas cut by 91–99 % (compare_web_captures: 155,623 → 1,392). Add mcp__github__ to shadowPrefixes and it becomes 182 tools, 776,706 → 143,679.

2. Cost attribution — where the re-sent context actually goes

It records every tool result (chars → tokens, duplicates, errors) and every billed step's usage, then derives the numbers that matter:

prompt       = input + cacheRead + cacheWrite
new content  = input + cacheWrite            ← paid at full price
equivalent   = 0.1 × cacheRead + new content ← comparable across requests

It also classifies the current context (user / assistant / tool call / tool result / reasoning) by character share, so "history is the biggest line item" is a measurement, not a guess.

3. A settings page

Settings → Cache saver shows cost per request, cache hit rate, new paid content, tool-result volume, the schema savings table, per-session stats, recommendations and a recent-events timeline. Data comes from GET /api/cache-saver/status (same origin, read-only).

Config

Put overrides in ~/.dsh/profiles/desktop/cordis.patch.yml (the durable layer):

- id: cache-saver
  name: '@local/dsh-cache-saver'
  config:
    shadowPrefixes: ['mcp__rea__', 'mcp__github__']
    maxSchemaChars: 800
key default meaning
shadowPrefixes ['mcp__rea__'] tool-name prefixes to slim
keepFull 8 core rea readers never slimmed
maxSchemaChars 800 target size per schema
maxDescriptionChars 260 target size per description
bigResultTokens 6000 "big result" threshold
maxStepSamples 60 step samples kept per agent
dryRun false measure only, do not shadow

Fine-tuning: minChars 700, maxDepth 3, topDescriptionChars 140, nestedDescriptionChars 60, descriptionDepth 1, maxBranches 4.

Why not just raise the cache hit rate?

Because hit rate and spending move in opposite directions here. A hit rate of 99 % means almost every token is a cheap cache read — but the denominator is whatever you keep re-sending. Deleting 136 K stable characters lowers the ceiling while genuinely cutting the bill. Track equivalent tokens, not the ratio.

Safety and limits

  • Dispatch, arguments and results are untouched; only the model-facing schema copy shrinks.
  • Rare deep parameters can be folded away — add that tool to keepFull, or set dryRun: true to turn the whole thing off.
  • v0.3.1 still ships one payload measurement caveat: tool-result volume is attributed by chars / 4, while step costs use the provider's real usage.

Development

npm test        # unit + client checks, no harness needed
npm run check   # syntax check

License

MIT

Content from the project README on GitHub ↗

Links

More in this category

View the whole category →

Community comments

Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.