DeepSeek Harness (DSH) uses @deepseek-ai/dsh-compaction-basic by default to manage the trigger threshold for context compaction. The formula is floor(min(W × 0.8, W − O − 65536)). Here, W is the context window and O is the output reserve. When a model’s configured output limit is high, the W − O − 65536 term can push the threshold very low. For example, with K3-256K and a 128K output reserve, the trigger threshold is only 25% of the window. dsh-compact-manager is designed to address this issue and lets you customize the trigger point for “when to compact”.

Plugin Overview

dsh-compact-manager is a hierarchical compaction threshold manager for DeepSeek Harness. It lets users override the automatic compaction trigger point at three levels: global → context length tier → model, and lets them check the currently effective threshold and policy for each model in real time from the sidebar.

  • Maintainer: frankshi2024
  • License: MIT
  • Category: model inference

Core Features

Three-level Policies and Priority

Policy priority runs from low to high; higher levels override lower levels:

  1. Global: Applies to all routes.
  2. Context length tier: A window length within ±5% of a tier value belongs to the same tier (if multiple tiers overlap, the nearest one is used).
  3. Model: An exact provider/model route.

Each level is a complete selection: the four policy items are each only “enabled / disabled”, with no “inherited” state. If a higher level exists, it fully overrides the lower level.

Policy Formulas

Each policy item supports the following formulas (used with a numeric value):

  • ratio: W × v (context ratio)
  • outputAware: W − O − v (subtracts output reserve and a fixed value)
  • fixed: W − v (subtracts only a fixed value)
  • absolute: v (hard-coded threshold; only available at the tier and model levels — it directly overrides other items when v < W, and never triggers when v ≥ W)

After installation, a Compaction Policy page appears in the sidebar:
- Real-time view: Select any known route to view W, O, the currently effective threshold, and the official built-in threshold.
- Apply presets: One-click apply common policies (for example, 256K tier: 80% or context-32K).
- Auto-refresh: The page refreshes automatically every 5 seconds and also when the window gains focus.

Installation and Enablement

Install the plugin with the official CLI:

dsh plugin --profile <profile> add dsh-compact-manager

After installation, the Compaction Policy page appears in the sidebar. If it does not appear, refresh the browser page. For local link: installations, make sure the plugin repository has run pnpm install (it depends on zod).

Typical Usage

  1. Open the Compaction Policy page in the sidebar.
  2. Select the target model from the model dropdown and view its W (context window), O (output reserve), and the currently effective threshold.
  3. Select a policy in the Presets area (for example, 256K tier: 80% or context-32K).
  4. Save the policy to persist the configuration.

Use Cases and Notes

  • Use cases: For users who need fine-grained control over when context compaction is triggered, especially to avoid triggering compaction while window usage is still high and causing history loss.
  • Permissions note: The plugin runs with the permissions of the current DSH process; inspect the source code and license before installing.
  • Known limitations:
    • It only overrides pressure-triggered compaction; context overflow recovery (context-overflow) still uses the official path.
    • It only changes the trigger threshold; it does not change the retention ratio for a compaction (the built-in backend still keeps the most recent 16% × (W − O)).
    • The model dropdown depends on ctx.llm.listProviders(); unauthenticated providers are unavailable, so you cannot add a new override for them (existing entries remain visible).

Ecosystem Background

DeepSeek Harness follows the philosophy that “everything is a plugin”. This is a community plugin. The catalog and GitHub links are as follows: