Preface

Long conversations are an inescapable problem in agent development: multi-turn tool calls, a large pile of intermediate results stacked in the context, and the window filling up after a few turns. A common approach is to set a threshold; once triggered, the system automatically summarizes it—the model itself has no say in what gets compressed or retained; it is entirely determined by external rules.

dsh-asc takes a different path: letting the model decide when and what to compress, and submitting every compression as a persistent session log replacement event—replayable, searchable, and reversible. DSH’s philosophy is “everything is a plugin,” and compression can be pluginized too. Below is an introduction to the positioning, working method, installation steps, and notes of this plugin.

What is it

dsh-asc, full name DeepSeek Harness Agentic Surface Compaction, is a context compression plugin for DeepSeek Harness (hereinafter referred to as DSH), maintained by lmst2, under the MIT license.

It registers with DSH’s ctx.compaction interface, replacing the default basic compression backend. The core idea is: compression is not an external rule imposed on the model, but a set of tools actively used by the model. Every compression is submitted as a replacement event in the logs (surfaceOp: replace), with the original content retained in the session log, ready to be decompressed or searched anytime.

Core Design: Model Autonomy and Layered Compression

After installation, the plugin works on three levels:

  1. Injects context management discipline into the system prompt, including judgment rules, tool usage, and layered compression pacing; the model actively manages the context from the first turn of the conversation.
  2. When context usage is high, injects nudge prompts on demand. Nudges are rhythmically gated; iterative nudges require actual token growth, preventing repeated urging every turn.
  3. Provides deterministic degradation when overflowing or manually compressing—directly falling back to LLM summarization. Optionally, when mounting upstream trimmers, it also performs tool result pruning, not relying on model cooperation.

Layered compression is divided into three levels:

  1. T1 Full Details: Captures the consumed raw work content into a checkpoint.
  2. T2 Refined Decisions: Refines the accumulated T1 content into decisions.
  3. T3 Fact Index: Further condenses T2 content into a fact index.

The more a summary is reused, the thinner it becomes. Each checkpoint text is tagged with a topic and a Compaction ID. When a summary on the interface points to the needed details, the model decompresses that section directly; context_search is only used when there is no visible summary indicating the location of the details. Decompression always happens layer by layer.

Five Model Tools

The plugin provides five tools to the model:

Tool Purpose
context_status View context usage, layered checkpoints, system/conversation composition, recommended intervals, and recent surface nodes
context_compress Replace a surface interval with a custom checkpoint (supports batching, automatic expansion for tool-call pairs, quality gating)
context_decompress Undo a compression: the original text returns to the position of the original checkpoint (tier-aware; full: true reaches original content)
context_recap Re-read checkpoint summaries without decompressing the original text
context_search Perform full-text search on the entire log, including compressed content

How Compression is Implemented: Event Sourcing

It is implemented based on Event Sourcing at the bottom. A single compression is a transaction in the log:

compaction/start → compaction/summary → replaced user/message → compaction/end

This brings four properties:

  1. Side-effect-free state files—compression only produces log events, no extra state.
  2. Reversible—decompression is achieved by replaying the obscured events in the log and submitting an in-place replacement event.
  3. Auditable—who compressed what, the full summary text, and token costs are all recorded in the log.
  4. Searchable—full-text search over the full log covers the compressed original content; compression does not cause information loss.

Installation and Enabling

Prerequisites: DeepSeek Harness installed (the dsh CLI is available); Node.js ^22.19 or >=24.

Install from npm (recommended):

dsh plugin --profile <name> add dsh-asc

To use a commit newer than the npm release, install from GitHub:

dsh plugin --profile <name> add github:lmst2/dsh-asc

To modify the plugin itself or contribute, build from source:

git clone https://github.com/lmst2/dsh-asc.git
cd dsh-asc
pnpm install
pnpm build
dsh plugin --profile <name> add "link:$(pwd)"

dsh plugin will add the plugin to the profile and enable it automatically based on the dsh.bundle declaration in the package. Tools and system prompts are loaded with the profile. The running DSH service needs to be restarted after installation.

Next, disable the default basic backend in cordis.patch.yml in the same profile—ctx.compaction only allows one provider at a time:

- id: compaction-basic
  disabled: true

You can also optionally mount runtime invariant checks and full-text search backends:

- insert:
    - id: dsh-asc-invariant          # Runtime invariant checks (optional, recommended)
      name: "dsh-asc/invariant"
    - id: session-query-sqlite       # context_search full-text backend (optional)
      name: "@deepseek-ai/dsh-session-query-sqlite"

Typical Usage

After the steps above, no extra configuration is needed after installation and restart. The plugin’s runtime loop is: capturing consumed raw work into a T1 checkpoint, refining accumulated T1 content into T2 decisions, and then condensing T2 content into a T3 fact index.

Typical model actions:

  1. Use context_status to view current usage and layered checkpoint distribution.
  2. Use context_compress to compress intervals where the original text is no longer needed.
  3. When details are needed, prioritize decompressing the corresponding checkpoint; when no clues are found, use context_search to search the full log.
  4. Use context_recap to re-read summaries without decompressing the original text.

Suitable Scenarios and Notes

Suitable scenarios:

  1. DSH users with long conversations and multi-turn tool calls, with tool results and intermediate outputs piled up in the context.
  2. Teams who want the compression process to be auditable and traceable—every compression’s executor and token costs are in the log.
  3. Developers who want to control the compression strategy themselves—just install from source to modify.

Notes:

  1. The plugin runs with the permissions of the current dsh process; please check the source code and license before installing.
  2. ctx.compaction only allows one provider; you must disable compaction-basic first.
  3. Compressed content is not lost: the original text is retained in the session log and can be decompressed or searched at any time.
  4. The license is MIT; the algorithmic ideas are inspired by opencode-acp (AGPL), but only the ideas are used, not the source code. See the NOTICE file in the repository for details.

Conclusion

The value of dsh-asc lies in giving the model the authority to decide on compression, while using Event Sourcing to ensure every step is replayable, searchable, and reversible. If you run long conversations on DSH, it is worth a try.

The plugin is listed in the community directory: https://www.skillhub.cn/plugins/lmst2/dsh-asc
Source repository: https://github.com/lmst2/dsh-asc