Enhanced auto-compaction defaults for DeepSeek Harness agent presets: apply tuned threshold/retention budgets and per-model policies with one command, idempotent with backups and rollback.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:songoao25/dsh-auto-compact
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. Only install sources you trust, and pin a commit (github:owner/repo#sha).
README
English | 中文
Enhanced auto-compaction defaults for DeepSeek Harness.
DeepSeek Harness ships automatic context compaction (dsh-compaction-basic), but the default trigger threshold is 80% of the model's context window — too late for large-context models. This tool lowers the threshold to 75% and adds per-route policies, so history is tidied up earlier and long sessions stay responsive.
How it works
DeepSeek Harness runs one compaction-basic instance per agent preset (per session). Profile-level patches cannot reach that subtree, so this tool directly injects configuration into the compaction-basic entry of every user-installed preset under ~/.dsh/.agent-presets/.
- Default: trigger at 75% of the context window, keep the most recent 20% verbatim.
- Per-route policies:
- ChatGPT / Codex GPT-5.6 (272K context): trigger at 70%.
- OpenCode Go DeepSeek V4 (1M declared context): trigger at 65%.
- Keeps the existing summarization, retry, and safe-fallback behavior of
dsh-compaction-basic(a failed summary preserves the original history and never silently drops context). - Manual
/compactand tool-result pruning remain available.
Installation
cd dsh-auto-compact
./install.sh
Restart DeepSeek Harness afterward. Roll back with:
./uninstall.sh
Important: Factory Presets
This tool only injects into user-installed presets under ~/.dsh/.agent-presets/. The factory presets (standard, code, cordis, minimal) ship with their own default compaction settings (80% trigger, 16% retain) and are read-only — this tool will not modify them.
If you want enhanced compaction for a factory preset:
- Copy it to your user presets directory:
cp -r /opt/homebrew/lib/node_modules/@deepseek-ai/dsh/presets/<preset-name> ~/.dsh/.agent-presets/ - Run
./install.shagain to inject the enhanced configuration. - Select the copied preset in DSH's session setup.
What the installer does
- Finds every
agent.cordis.ymlunder~/.dsh/.agent-presets/. - Injects the policy block into the
compaction-basicentry of each preset. - Backs up each modified file as
agent.cordis.yml.bak-auto-compact. - Idempotent: a marker comment prevents double injection.
- Skips presets that already configure
compaction-basicthemselves (merge manually in that case). - Never touches the read-only factory presets in the DSH install directory.
Configuration
All values live in scripts/inject.mjs (the CONFIG_BLOCK). Edit them before running ./install.sh if you want different thresholds. Preview with:
node scripts/inject.mjs --dry-run
| Key | Default | Meaning |
|---|---|---|
thresholdRatio |
0.75 | Trigger compaction when estimated usage reaches this fraction of the model context window |
retainRatio |
0.20 | Keep the most recent fraction of the window verbatim |
modelPolicies |
– | Per provider/model overrides |
Safety
- A failed summarization preserves the original history and logs a warning.
- Automatic recovery never loops indefinitely (bounded retries).
- The tool contains no secrets and no personal paths.
- Installation is fully reversible via
./uninstall.sh.
License
MIT © songoao25
Links
More in this category
volcengine/OpenViking#examples/dsh-memory-plugin★ 28738
OpenViking memory and context bundle for DeepSeek Harness: pre-step auto-recall and profile injection, session capture, `viking://` URI guarding, and recall/write memory tools backed by an OpenViking server.
vectorize-io/hindsight#coding-agents★ 20063
Hindsight, agent memory that learns: long-term project memory with auto recall and retain, knowledge pages, deep reflection, and per-repo memory banks.
dsh-engramory★ 155
The Engramory curated-memory discipline as an installable plugin ([npm: dsh-engramory](https://www.npmjs.com/package/dsh-engramory)): a deterministic 200-line / 25 KB cap on the `MEMORY.md` index via `ctx.tools.guard()` — growth denied, a shrinking rewrite always passes — plus the protocol registered as a runtime skill. The store is plain markdown, one file per fact, shared with Claude Code, Codex, Kiro, and OpenClaw.
bowenliang123/dsh-context★ 121
Context insight panel: see what the model's context window is made of and how it evolves — composition vs. window size, per-request history, compression/injection events, and per-message token stats.
omdsh-dev/dsh-mnemon★ 62
Cross-agent, local-first persistent memory plugin for DeepSeek Harness (DSH), powered by Mnemon. It shares long-term memory across Mnemon-enabled agents and adds runtime memory, searchable project documents, semantic recall, knowledge graph, and a Sidebar UI.
modusensus/dsh-mneme#dsh-mneme★ 20
Structured memory engine for DeepSeek Harness. Offline semantic search, entity-attribute-timeline, autoDream self-consolidation, and human-editable Markdown storage.