Preface

When running long conversations or tasks in DeepSeek Harness (DSH), the context window will eventually be filled. The common practice is to hard-truncate at a fixed upper limit, silently discarding early messages, leading to the loss of paths, decisions, and error information. DSH’s built-in compaction-basic replaces a range with an automatically generated summary, but the summary is written by another LLM call, and the timing and range are not controlled by the current model.

billion-context-dsh takes a different approach: it connects Active Context Pruning (ACP) to DSH’s CompactionEngine, providing the model with four tools—compress, decompress, search_context, and acp_status—allowing the model to decide when and what to compress. The compression kernel comes from acp-kernel, the overall structure is ported from billion-context-pi, and the adaptation layer is rewritten for DSH’s durable-surface model. The maintainer is Tyan66666, the current version is v0.2.13, licensed under MIT; the README explicitly marks it as a beta version, not for production use.

What Is This

billion-context-dsh is a context compression plugin for DSH, classified as a model inference-related capability. It registers as the compaction-acp backend, mounting four model tools, the /acp command, nudge prompts, and the ACP system prompt segment on the host plane. The automatic strategy only nudges, not forcing summarization; compactIfNeeded returns null, performing no automatic unified compression.

Compared to hard truncation, the compressed summary becomes a checkpoint node, with the original text preserved in an append-only session log. It can be restored using decompress or searched within chunks using search_context.

Core Features

Model-Driven Compression

The model uses the compress tool to replace a specified seq range with a high-fidelity summary written by itself. Boundaries are automatically aligned to tool-call/result pair points. Compressing a chunk summary node again results in hierarchical distillation (tier 2/3), with tier and chunk ID written to the log. After restart, it is rehydrated from the log.

Four Model Tools

Tool Function
compress Replaces a seq range with a compact summary; compressing a chunk summary again = hierarchical distillation
decompress Read-only restoration of the original text of a compressed chunk; accepts bN or compaction ID from acp_status
search_context Rebuilds chunk summaries and masked original text from the log, then passes them to acp-kernel’s searchBlocks for hybrid retrieval (stemming, CJK bigram, character n-gram fuzzy matching), returning the chunk ID of hits
acp_status Reports context breakdown (tool/text/summaries proportions), compressed chunk ledger, nudge decision lines, and checkpoint seqs; supports scope/view/tool/sort/limit drilling

Nudge and Persistence

When context pressure is high, the kernel injects a nudge in agent/pre-step: efficiency tips, context breakdown, compression rules, and compressible range tables. This is a suggestion, not a command. Compression corresponds to surfaceOp: { op: 'replace' }, with the original text still in the log; chunk status is maintained by the in-memory kernel plus the log ledger, with no sidecar files.

Differences from DSH’s Built-in Compression

  • Summaries are written by the current model, with no second LLM summarization call
  • Only nudges, not forces; whether to compress is decided by the model
  • Compressed ranges are recoverable and searchable; key conclusions in long tasks can be retained cumulatively
  • Context remains concise per request, avoiding detail decay from large-scale unified compression

The bundle installation disables the host’s compaction-basic to avoid conflicts between two ctx.compaction backends in the same realm. The shipped presets (standard / code / cordis) retain the realm-level compaction-basic internally, with ACP tools and nudge coexisting alongside it; minimal presets without compaction realms use this engine directly.

Installation and Enabling

The plugin runs with the current dsh process privileges. It is recommended to read the source code and LICENSE before installation. Requires Node.js >= 20; peer dependency @deepseek-ai/dsh-compaction is ^0.1.0-rc.6 || ^0.1.1-rc.1.

Install via the DSH plugin store, or run:

dsh plugin --profile web add billion-context-dsh

This command installs the npm package and mounts cordis.patch.yml into the profile’s layer stack: disabling host compaction-basic and mounting the ACP engine on the host plane. Window detection is automatic; tools, commands, and nudges are all enabled by default, requiring no manual configuration.

After installation, restart dsh (bundle layers combine at startup), and start a new session. Have the model call acp_status or execute /acp status to verify if it is active.

You can also directly install the npm package:

npm install billion-context-dsh

When used with the above dsh plugin command, the package is installed together; a standalone npm install will not touch the profile and requires manual composition lines.

Method 2: Pure npm Installation with Manual Composition

npm install billion-context-dsh

Append to the profile patch (e.g., ~/.dsh/profiles/web/cordis.patch.yml):

# Must disable host compaction-basic to avoid ctx.compaction conflicts
- id: compaction-basic
  disabled: true

- insert:
    - id: compaction-acp
      name: 'billion-context-dsh'
      config:
        modelContextLimit: 128000   # Optional; auto-detects model window if omitted, defaults to 128000

For bundle users who only want to change configuration, override with the same ID:

- id: compaction-acp
  name: 'billion-context-dsh'
  config:
    modelContextLimit: 128000

Optionally customize nudge text and tool descriptions via config.prompts; typos in placeholders will cause a fail-fast at engine startup. See docs/configurable-prompts-design.md for details.

Complete installation and verification steps are in docs/INSTALL.md. If you want the DSH agent to handle installation, provide this document to the agent in the session to edit configuration under ~/.dsh and call acp_status for verification (requires file permission approval).

Typical Usage

Verifying Plugin Mount

In a new session, have the model execute:

/acp status

Or call the tool acp_status; it should return CONTEXT BREAKDOWN, compressed chunk ledger, and nudge-related information.

Compressing a Conversation Segment

When the nudge indicates high context usage, the model can call compress, specifying a seq range and attaching a summary. For example, compress the exploration process in seq 10–50, retaining file paths, key decisions, and error information in the summary. After compression, the context is shortened, with the original text still in the log.

Restoration and Retrieval

To verify early details, use decompress with the bN chunk ID displayed by acp_status. To search for keywords across multiple compressed chunks, call search_context, which uses kernel hybrid retrieval and links back to the hit chunks.

Hierarchical Distillation

Compressing the summary node of an existing compressed chunk results in tier 2 distillation for that chunk; compressing a tier 2 chunk yields tier 3. This is suitable for gradually condensing old segments in ultra-long tasks while preserving a restorable checkpoint structure.

Applicable Scenarios and Notes

Who Is It For

  • Developers running code agents, long document analysis, multi-step debugging, and other ultra-long sessions on DSH
  • Scenarios where context is compressed by the model as needed, rather than hard-truncated or automatically summarized in bulk
  • Users already using or planning to use the DSH web profile (bundle for one-click mounting)

Notes

  • v0.2.13 and DSH itself are both beta versions; the README states not for production or engineering use, with expected breaking changes
  • Only one ctx.compaction backend is allowed per realm; do not coexist with compaction-basic
  • shadowedTokenCount uses the host token-meter pricing, not mixed with internal CJK estimation
  • The SkillHub directory page is a community site, with no official affiliation with DeepSeek / High-Flyer; installation commands follow the README and dsh plugin

Conclusion

billion-context-dsh connects ACP’s “model decides when and what to compress” to DSH’s durable-surface: four tools, recoverable logs, nudge reminders, and hierarchical distillation, targeting long-task context management. Approximately 43 stars and 5 forks on GitHub.

  • Directory page: https://www.skillhub.cn/plugins/Tyan66666/billion-context-dsh
  • GitHub: https://github.com/Tyan66666/billion-context-dsh
  • npm: billion-context-dsh