DeepSeek Harness plugin

dsh-auto-compact-lileikej

Auto context compaction for DeepSeek Harness: token-pressure-driven summarization checkpoints with a configurable (LATE-by-default) trigger threshold and a settings card.

Jump to install

Source facts

Repository
lileikeji/dsh-auto-compact
Latest update
Aug 20, 2026
Category
Memory
GitHub stars
0
Format
plugin
Catalog evidence
Upstream dsh.bundle evidence
Evidence path
package.json#dsh.bundle
Checked against
0.1.0-rc.8
Upstream check date
2026-08-20

This evidence comes from the upstream catalog. This site has not installed, run, or security-reviewed the plugin.

Install

Start with a prompt that asks an agent to review the GitHub repository and source. Switch to the command if you want to install it yourself.

Copy this prompt into DSH, Codex, or another agent and ask it to review the GitHub repository and source first.

Do not install or run any commands yet. Read this plugin's GitHub repository, README, and relevant source code. Then answer the questions below clearly and directly so I can decide whether it fits my needs:

1. What is this plugin, and what problem does it solve?
2. Who is it for, and what are its typical use cases?
3. How is it used after installation? Include one minimal example.
4. What known limitations or privacy, security, compatibility, or maintenance risks does it have?
5. Give a clear recommendation: recommend, conditionally recommend, or do not recommend, with reasons.

Distinguish statements documented by the repository, inferences from source code, and unknowns. If evidence is insufficient, say so explicitly. Do not guess or simply repeat the README.

GitHub: https://github.com/lileikeji/dsh-auto-compact
Plugin: dsh-auto-compact-lileikej
Author: lileikeji

Check the source files

Read the README and other files from this plugin directory before installing.

File explorer3 files
README.mdSource · read only

dsh-auto-compact

Automatic context compaction for DeepSeek Harness: at every agent step it prices the routed request against the model's context window, and once pressure crosses the configured threshold it condenses the older span of the conversation into a durable <compacted-summary> checkpoint (via the conversation's own model, reusing the warm prefix cache) — so long sessions keep working without losing essential context.

It wraps the harness's own token-meter-driven engine (@deepseek-ai/dsh-compaction-basic); this plugin adds a LATE-by-default trigger, a settings card, and install docs.

Why "compact later"?

The harness's pi-ai provider falls back to DEFAULT_CONTEXT_WINDOW = 262144 (256K) for models that do not declare a window. With the default thresholdRatio of 0.8 that means compression can fire at ~205K tokens — only ~20% of a real 1M-window model. This plugin defaults to thresholdRatio: 0.92 and documents the window fix, so big windows are actually used.

Install

# profile dir (C:\Users\<you>\.dsh\profiles\<name>)
pnpm add -w dsh-auto-compact
# or from GitHub:
pnpm add -w dsh-auto-compact@github:lileikeji/dsh-auto-compact

Add dsh-auto-compact to the profile package.json dsh.profile.bundles list, then disable the harness's own engine so only one engine owns compaction:

# profile cordis.patch.yml
- id: compaction-basic
  name: '@deepseek-ai/dsh-compaction-basic'
  disabled: true

Window configuration (important)

The engine reads the model's context window from the LLM adapter. If your model's window is not declared (pi-ai defaults to 256K), set it per provider in ~/.dsh/settings.yaml:

llm-pi-ai:
  providers:
    my-provider:
      apiKeyEnv: MY_API_KEY
      defaultContextWindow: 1000000   # the model's real window

Configuration (settings card)

Settings → 插件 → 自动压缩上下文(auto-compact):

  • thresholdRatio — trigger threshold as a fraction of the context window (default 0.92).
  • retainRatio — fraction of the recent conversation kept verbatim (default 0.12).
  • maxTokens — summary output cap (default 8192).
  • auto — enable/disable automatic compaction.

Changes apply after a profile restart.

How it works

1. agent/pre-step: price the latest durable routed request with the token meter. 2. If totalTokens ≥ thresholdRatio × contextWindow (output-budget aware when known), pick a head-anchored span that never splits a tool call/result pair, retaining the recent tail. 3. Summarize that span with the conversation's own model (system prompt + tools + leading messages replayed verbatim so the provider's KV cache is reused), appending the compaction instruction. 4. Land the checkpoint as a compaction/start → summary → compaction/end transaction on the session surface; subsequent steps continue from the checkpoint.

License

MIT