dsh-web
zhu1090093659/dsh-webDeepSeek Harness(DSH)Web 插件聚合生态包 · 一切皆插件,创意工坊分发(dsh-market.com)
Deterministic, zero-LLM, byte-budget context compaction for DeepSeek Harness, with byte-exact recall of compacted history
Deterministic, zero-LLM, byte-budget context compaction for DeepSeek Harness (DSH), with byte-exact recall of everything it compacts.
Long DSH sessions eventually fail because every request re-uploads the whole
conversation. dsh-hypercompact keeps that request small: when it grows past a
byte limit, it compacts old history locally in milliseconds, with no extra model
call. Everything you typed stays word for word, and the agent can restore any
compacted tool output exactly with the recall tool.
Contents: Supported DSH versions · Installation · Preset not in the picker? · Check that it is working · Which sessions use it? · Uninstall · Why this plugin exists · Configuration · How it works · Recall tools · Requirements · Known limits
dsh-hypercompact 0.2.4 works with DSH 0.1.5-rc.2 through 0.2.x (not
0.3.0 or later). Check your installed Harness with dsh --version.
| DSH version | npm tag checked 2026-10-05 | Verified with dsh-hypercompact 0.2.4 | Preset created by create-preset.mjs |
|---|---|---|---|
0.2.1-alpha.1 | alpha | ✅ Tested | preset bundle, installed with dsh plugin add |
0.2.0-rc.2 | latest / next | ✅ Tested, including durable image-offload projections | preset bundle, installed with dsh plugin add |
0.2.0-rc.1 | — | ✅ Tested | preset bundle, installed with dsh plugin add |
0.1.7-rc.2 | — | ✅ Tested | preset bundle, installed with dsh plugin add |
0.1.5-rc.3 | — | ✅ Tested | folder ~/.dsh/.agent-presets/hypercompact/ |
0.1.5-rc.2 | — | ✅ Tested | folder ~/.dsh/.agent-presets/hypercompact/ |
Other 0.1.5-rc.2 … 0.2.x releases | — | ⚠️ Not verified: allowed after an API check, with a warning; behavior is not guaranteed | detected automatically |
0.1.5-rc.1 and older | — | ❌ Not supported: no compaction API | — |
0.3.0 and newer | — | ❌ Refused until tested (override: allowUntestedHarness: true) | — |
Which dsh-hypercompact version do I need?
| dsh-hypercompact | Harness range allowed by its version gate | What changed |
|---|---|---|
0.2.4 (recommended) | >=0.1.5-rc.2 <0.3.0; tested on the six versions above | recall accepts the placeholder arguments some models send (result: 0, range: "", …) |
0.2.3 | >=0.1.5-rc.2 <0.3.0 | create-preset.mjs repairs stale preset rows that hid the preset |
0.2.2 | >=0.1.5-rc.2 <0.3.0 | Handles DSH 0.2 content-only image offload |
0.2.0–0.2.1 | >=0.1.5-rc.2 <0.3.0 | Older image handling; update for the DSH 0.2.0-rc.2 image-offload fix |
0.1.0 | >=0.1.5-rc.2 <0.2.0 | Refuses to load on DSH 0.2 |
"Refused" means the plugin logs a clear error at startup and does not load; it does not attempt compaction. Releases in the allowed range have different preset installation models (Step 2 below), and an API check alone does not establish full runtime compatibility. After upgrading DSH, see Upgrading DSH.
Installing takes three steps: add the package, create a preset that uses it, and start a new session on that preset. The package on its own does nothing. DSH picks a compaction engine per preset, so the plugin runs only in sessions that use a preset containing it.
dsh plugin --profile web add dsh-hypercompact
# GitHub
dsh plugin --profile web add github:mrbeandev/dsh-hypercompact
# Local checkout (keep the folder in place: the profile links to it)
git clone https://github.com/mrbeandev/dsh-hypercompact.git
dsh plugin --profile web add "link:$PWD/dsh-hypercompact"
node ~/.dsh/profiles/web/node_modules/dsh-hypercompact/scripts/create-preset.mjs
This copies DSH's built-in standard preset and changes one row: the
compaction engine. Your existing presets are not touched. The script detects
your DSH version and does the right thing for it:
DSH 0.1.7 and 0.2: it writes a small preset bundle to
~/.dsh/hypercompact/preset-hypercompact/ and installs it into the profile for
you (it runs dsh plugin --profile web add itself). Output ends with:
+ dsh-hypercompact-preset link:~/.dsh/hypercompact/preset-hypercompact
DSH 0.1.5: it writes the preset folder ~/.dsh/.agent-presets/hypercompact/:
created preset "hypercompact" at ~/.dsh/.agent-presets/hypercompact
Not sure which DSH you have? Run dsh --version.
node %USERPROFILE%\.dsh\profiles\web\node_modules\dsh-hypercompact\scripts\create-preset.mjsDSH_HOME: use that directory instead of ~/.dsh.node /path/to/dsh-hypercompact/scripts/create-preset.mjsdsh web).To use it for every new session instead, make it the default:
DSH 0.1.7 and 0.2: in the web UI's preset picker, set Hypercompact (standard) as your default preset.
DSH 0.1.5: add this to ~/.dsh/settings.yaml and restart DSH:
agent-presets:
default: hypercompact
On DSH 0.1.7 and later, your profile's own ~/.dsh/profiles/web/cordis.patch.yml
applies after every bundle. If it still contains a preset-hypercompact
row, typically disabled: true left behind when the preset was disabled or
uninstalled, or an inline declaration from an older version of the script,
that row hides the preset.
Upgrade to dsh-hypercompact 0.2.3 or later and run the script again with
--force. It removes those stale rows, keeps the previous file as
cordis.patch.yml.bak-hypercompact, and prints what it removed:
dsh plugin --profile web add dsh-hypercompact@latest
node ~/.dsh/profiles/web/node_modules/dsh-hypercompact/scripts/create-preset.mjs --force
Then restart DSH. To fix it by hand instead, delete every preset-hypercompact
row from that file (the preset bundle declares the preset itself).
In the session, type:
/hypercompact
Compaction then happens on its own when the request grows past 5 MB. You can
also run /compact at any time.
| Session | Uses dsh-hypercompact? |
|---|---|
| New session with Hypercompact (standard) picked before the first message | Yes |
| Any new session, after you make Hypercompact the default preset | Yes |
New session on another preset (standard, ptc, …) | No |
| Existing session (already has messages) | No. DSH fixes a session's preset after its first message, so it can't switch compaction engines mid-conversation. |
Moving an existing conversation over: start a new Hypercompact session and
mention the old one with @ (pick it from the list). DSH inserts a size-limited
snapshot of that session so the agent can continue from it.
After you upgrade DSH (for example 0.1.5 → 0.2), do two things:
Update the plugin, since a plugin release only accepts the DSH versions it knows:
dsh plugin --profile web add dsh-hypercompact@latest
Regenerate the preset. It is a copy of DSH's standard preset at the
time you created it, so re-run the script to follow the new version:
node ~/.dsh/profiles/web/node_modules/dsh-hypercompact/scripts/create-preset.mjs --force
Then restart DSH.
Going from 0.1.5 to 0.1.7 or later, this is required: newer DSH no longer reads
~/.dsh/.agent-presets/, so the old preset silently disappears from the picker.
The script creates the new-style preset and deletes the old folder it made.
Script options: --from ptc (copy another built-in preset), --id my-preset,
--profile tui (default web), --force (overwrite / regenerate), --print
(preview, write nothing), --no-install (0.1.7+: write the bundle but don't run
dsh plugin add), --remove (delete everything the script created).
Remove the preset first. A preset that still names the package cannot load once the package is gone.
node ~/.dsh/profiles/web/node_modules/dsh-hypercompact/scripts/create-preset.mjs --remove
dsh plugin --profile web remove dsh-hypercompact
--remove uninstalls the preset bundle (0.1.7+) or deletes the preset folder
(0.1.5). If you made Hypercompact your default preset, pick another default (or
remove agent-presets.default from settings.yaml on 0.1.5). Sessions that were
already compacted stay readable: their checkpoints are ordinary compaction
checkpoints in the session log.
To put the plugin in your own preset instead of using the script, replace the
compaction-basic row inside the preset's compaction group. Keep the
isolate block: /compact and the engine must share that group.
- id: compaction
name: cordis:group
group: true
isolate:
compaction: true
toolResultPruner: true
config:
- id: hypercompact # was: compaction-basic
name: dsh-hypercompact
config:
maxRequestBytes: 5000000
targetRequestBytes: 1500000
- id: command-compact
name: '@deepseek-ai/dsh-command-compact'
- id: tool-result-pruner
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
If you ever add a dsh-hypercompact row to a profile's cordis.patch.yml by
hand, delete it before uninstalling: a row naming a missing package stops the
profile from booting.
Every model call in a long agent session re-uploads the whole conversation. On a slow or proxied connection the request body size, not the token count, is what fails: a 20 MB request can take minutes to upload and hit a proxy's 100-second timeout before the model ever sees it. DSH then retries the same oversized request.
The built-in engine (@deepseek-ai/dsh-compaction-basic) cannot help there:
dsh-hypercompact measures the next request in bytes and compacts locally in milliseconds, with no model call. Measured on real sessions, inline screenshots were 50–92 % of the request body, and tool traffic most of the rest. The plugin targets both.
/goal round
prompts, and team messages.+N/−M lines summary for edits, and a pointer to the original. Runs of
read-only calls (read ×7: a.js b.js …) become one line.recall, which restores any original
byte-exact from the append-only session log (or just the matching lines of
a large one), plus recall_search. You get /recall and /hypercompact.ctx.compaction contract, so
/compact, the token meter and context charts keep working. No client bundle,
no settings UI, no patching of harness internals.Real sessions, measured offline with npm run measure (see
Development) through pi-ai's own OpenAI-completions
serializer, default configuration. No LLM calls are made.
| Session | Request before | Request after | Replaced | Checkpoint | Degradation | User messages kept verbatim | Time |
|---|---|---|---|---|---|---|---|
| A (images + tools) | 19.51 MB | 1.08 MB | 2302 | 503 KB | 1 | 31 / 31 | 149 ms |
| B (images) | 12.37 MB | 0.80 MB | 632 | 221 KB | 0 | 21 / 21 | 96 ms |
| C (images + tools) | 11.42 MB | 1.62 MB | 1337 | 278 KB | 1 | 27 / 27 | 123 ms |
| D (images) | 10.99 MB | 0.86 MB | 483 | 146 KB | 0 | 8 / 8 | 55 ms |
| E (~800k-token session) | 6.40 MB | 1.66 MB | 683 | 222 KB | 0 | 12 / 12 | 86 ms |
| F (mixed) | 3.01 MB | 1.09 MB | 581 | 195 KB | 0 | 2 / 2 | 67 ms |
| G (text only) | 1.11 MB | 0.59 MB | 809 | 229 KB | 0 | 8 / 8 | 68 ms |
Degradation 0 means only reasoning was dropped; 1 means tool-result excerpts
were dropped (call lines and pointers stay). No entry was elided in any
session. Every compacted request had 0 orphaned tool results and 0 unanswered
tool calls, and recall returned a sampled tool result byte-identical to the log.
All keys are optional. Unknown keys are rejected at mount, so a typo fails loudly instead of silently using a default.
| Key | Default | Meaning |
|---|---|---|
maxRequestBytes | 5000000 | Compact when the estimated next request body reaches this many bytes. |
targetRequestBytes | 1500000 | Compact down to about this. Must be below maxRequestBytes. The gap is the hysteresis: each compaction costs one prompt-cache miss, so compact in big steps. |
housekeepingRatio | 0.5 | Start housekeeping this fraction of the way from target to trigger (default: at 3.25 MB). Housekeeping offloads older images and trims old tool results in place; no checkpoint. 0 = off. |
housekeepingExcerpt | { head: 2000, tail: 1000 } | Characters a trimmed old tool result keeps. |
maxTokens | 0 | Also compact at this many estimated tokens (0 = off). |
contextRatio | 0.85 | Also compact at this fraction of the routed model's contextWindow (0 = off). The lower of the two token triggers wins. |
retainTurns | 2 | Newest complete turns never compacted. |
retainBytes | 400000 | Newest request bytes never compacted. |
allowIntraTurn | true | When one long autonomous turn holds the bytes, compact its older tool traffic, keeping the turn's human message and the newest retainBytes. |
maxCheckpointBytes / minCheckpointBytes | 600000 / 300000 | Bounds on the checkpoint. Its budget is the space actually free under the target after the retained turns (net of images about to be offloaded), clamped to these bounds. |
pinnedBytes | 30000 | Cap on the pinned block. Trimmed in order: the message index (to the newest 40 lines + a summary), the files list, then the oldest constraints. |
userTextChars | 20000 | Hard cap for ONE pathological human paste: above it, head + tail are kept with a recall pointer. Budget passes never cut human text. |
assistantTextChars | 1500 | Assistant text length in the checkpoint (head + tail); degraded passes never go below 1000. |
toolResultExcerpt | { head: 200, tail: 100 } | Excerpt of each compacted successful tool result. |
toolErrorExcerpt | { head: 600, tail: 400 } | Excerpt of each failed tool result (never dropped by budget passes). |
groupTools | [read, read_image, grep, glob, ls, web_search, web_fetch, recall, recall_search] | Consecutive successful calls to one of these tools collapse into one line. [] = off. |
keyArgChars | 160 | Max characters of one argument shown on a tool-call line. |
largeArgBytes | 2000 | Argument values larger than this are shown as <N KB>. |
keyArgTools | null | null = show key arguments for every tool; or a list of tool names. Other tools show only their argument size. |
keepRecentImages | 2 | Newest inline images kept; older ones become captioned labels when the request is above target. |
maxKeptImageBytes | 2000000 | Byte cap (base64) on the kept images, independent of the count. |
recoverOnTimeout | true | After a request timeout/transport failure with a body above the target, compact and retry once. Context-overflow and HTTP 413 failures are always recovered. |
maxRecoveryRetries | 1 | Recovery compactions per agent until it next goes idle. |
dryRun | false | Log what would be compacted; write nothing. |
auto | true | Automatic triggers. With false, only /compact compacts. |
tools | true | Register the recall and recall_search tools. |
commands | true | Register the /recall and /hypercompact commands. |
recallToolName / searchToolName | recall / recall_search | Tool names, in case another plugin already uses them. |
maxRecallChars | 60000 | Page size of one recall answer (longer output continues with offset). |
maxSearchHits | 30 | Max entries returned by one search. |
statsLog / statsDir | true / null | Append one content-free JSON record per compaction to <statsDir>/<session>.jsonl (default ~/.dsh/hypercompact/). |
modelPolicies | [] | Per-route overrides: [{ provider, model, maxRequestBytes?, targetRequestBytes?, maxTokens?, contextRatio?, retainTurns?, retainBytes?, maxCheckpointBytes?, housekeepingRatio? }]. |
harnessEntry | running dsh | Path of the dsh CLI entry, if it cannot be found from process.argv[1]. |
allowUntestedHarness | false | Load on a DSH release outside the supported range, or one that fails the API contract check. |
retainTurns: 2, retainBytes: 400000. The current and previous turn stay
verbatim, so the agent never loses the work in progress.contextRatio: 0.85. A token safety net for a small-window model whose
session stays under the byte trigger.keepRecentImages: 2. The screenshots the agent is currently looking at
survive, and older ones, the dominant cost in measured sessions, do not.minCheckpointBytes: 300000. Measured: with a smaller floor, sessions
whose retained tail is image-heavy got a tiny budget and elided hundreds of
entries; at 300 KB every measured session compiled with degradation ≤ 1 and
nothing elided, while still landing near the 1.5 MB target.On a fast connection with a large-window model you can raise both byte values (for example 20 MB → 6 MB); the token trigger still protects the context window.
Per-model policies. None ship by default, because provider and model IDs are
deployment-specific; provider and model must match your route exactly:
modelPolicies:
# a route behind a slow proxy: keep every request under ~30 s at ~100 KB/s
- { provider: my-gateway, model: my-model, maxRequestBytes: 3000000, targetRequestBytes: 1000000 }
# a 128K-window model: fire the token trigger early
- { provider: deepseek, model: deepseek-chat, contextRatio: 0.7 }
Trigger. Before every model step (agent/pre-step), the engine estimates
the next request body: each surface message serialized as JSON, inline images
as base64, plus the tool schemas and a fixed envelope. Per-message sizes are
cached by log seq and the log is folded incrementally, so a step costs
O(new events), not a rescan of the session. It compacts when the estimate
reaches maxRequestBytes, or when a token trigger fires.
Selection. It replaces the oldest span of the surface. The span never
includes the system prompt, never cuts between an assistant tool call and its
results, prefers turn boundaries, and never touches the newest retainTurns
turns or retainBytes bytes. It compacts enough that the result lands near
targetRequestBytes.
Checkpoint. The span is compiled into one user message with three parts:
pinnedBytes, the index is trimmed first (newest 40 lines plus one
"N older user messages: seq a–b" line), then the files list, and constraints
last.[user seq N] and [/user seq N] (or [agent-message seq N],
[goal seq N], [team-message seq N]). Assistant text is head + tail. Each tool
call is one line with its result's status, size and excerpt; runs of read-only
calls are one line. Harness-injected context (agent instructions, subagent
reports) is shortened. Reasoning is dropped.If the checkpoint exceeds its budget, the compiler degrades in fixed passes:
drop success excerpts, then shorten assistant text (never below 1000 chars)
and context, then elide the oldest unprotected entries (tool lines,
assistant text, context) behind [N entries elided, seq A–B] lines. Human
text, pinned lines, failed-call excerpts, and entries the model recently
recalled are never elided. If they alone exceed the budget, the budget is
exceeded (logged, and recorded in the stats) rather than dropping what the user
said. An earlier checkpoint in the span is re-parsed, not copied: its human
blocks stay protected with their original seqs, its pinned lines merge, and its
tool lines become elidable, so repeated compactions stay bounded.
A compiled tool line looks like:
• edit file_path="src/net/retry.ts" old_string="const timeout = 30_000" new_string=<3.2 KB> [+84/−1 lines] (seq 1822 → result 1824 ok 23 B)
"Edited src/net/retry.ts"
Commit. The same durable transaction as the built-in engine:
compaction/start → compaction/summary → user/message (surface replace)
→ compaction/end, with no await in between. The summary event carries the
standard fields (shadowedSeqs, shadowedTokenCount, …) that /compact and
dsh-context read. The original events stay in the log. If the request is
still above target, older images in retained tool results are replaced through
the harness's content-only tool-result rewrite (th