Intro

The operation of DeepSeek Harness (DSH) relies on the context window. As conversation turns increase or tool calls become frequent, historical messages can easily fill the context, causing request failures or making the model forget early instructions. The dsh-compact plugin addresses this issue by automatically compressing historical content, providing a manual compression entry point, and implementing an overflow recovery mechanism, enabling long conversations to continue.

Plugin Overview

  • Name: dsh-compact
  • Core Value: A DeepSeek Harness plugin for automatic context compression, manual compression, and overflow recovery
  • Maintainer: zixin947
  • License: MIT

Installation and Activation

Completely exit the running DSH service, then run the following command to install the plugin:

dsh plugin --profile web add "github:zixin947/dsh-compact#main"

After installation, restart the DSH Web service. The default mount configuration is provided by cordis.patch.yml:

- id: compact
  name: 'dsh-compact'

Configuration Options

The plugin provides the following configuration options, allowing you to control when compression is triggered, the retention ratio, and the overflow recovery strategy. The default values are as follows:

Option Default Value Description
enabled true Whether to enable automatic compression and overflow recovery
thresholdRatio 0.75 Trigger automatic compression when context usage reaches 75% of the window
retainRatio 0.20 Retain approximately the most recent 20% of the context after compression
recoverOnOverflow true Whether to attempt recovery when a context overflow error is encountered
maxOverflowRetries 1 Maximum number of overflow recovery retries
modelPolicies [] Override policies for specific models

Parameter Constraints

  • thresholdRatio must be between 0.50 and 0.95.
  • retainRatio must be between 0.05 and 0.50.
  • retainRatio must be less than thresholdRatio.
  • modelPolicies matches exactly using provider and model.

Configuration Example

- id: compact
  name: 'dsh-compact'
  config:
    enabled: true
    thresholdRatio: 0.75
    retainRatio: 0.20
    recoverOnOverflow: true
    maxOverflowRetries: 1
    modelPolicies:
      - provider: youchu
        model: deepseek-v4-flash
        thresholdRatio: 0.80
        retainRatio: 0.20

Usage

Basic Mount

General users only need to mount dsh-compact to obtain automatic compression and overflow recovery capabilities.

Agent-Level Mount

If the target Agent preset requires an independent compression entry point (such as the /compact command) or needs tool result pruning, mount dsh-compact/agent in the corresponding combination:

- id: compact-agent
  name: 'dsh-compact/agent'
  isolate:
    compaction: true
    toolResultPruner: true

This mount point combines the compression engine, the /compact command, and the tool result pruner.

Entry Points

  • Automatic compression: Automatically triggered before a normal request begins, based on the context usage ratio.
  • Manual compression: Manually triggered via the /compact command or the entry point in the settings page.

Working Mechanism

Automatic Compression Flow

Before each Agent request begins, the plugin checks the current context usage ratio. When the ratio reaches thresholdRatio:

  1. Select an earlier conversation interval to compress.
  2. Generate a structured checkpoint summary using the current session’s model.
  3. Replace the original interval with a persisted summary (retaining the most recent portion of context).
  4. Continue executing the original request.

Each pressure check generates at most one summary to avoid repeated compression within the same turn.

Overflow Recovery

When the model returns a context window limit error, the plugin attempts to compress the current session and retries the original request. Recovery attempts are limited by maxOverflowRetries, and requests being cancelled are not retried.

Empty Summary Fallback

If the summary model returns empty text, the plugin removes the Agent system prompt and tool definitions, then performs a fallback retry once. Other network or model errors do not trigger this fallback logic.

Notes

  1. File safety: The plugin only processes DSH session context and does not delete workspace files.
  2. Summary quality: Compression replaces the displayed content of earlier conversations with a summary; summary quality depends on the model currently in use.
  3. Fault tolerance: If automatic compression fails, the plugin records the status and continues the user request; it will not interrupt the current turn due to an abnormal summary service.
  4. Version dependency: This version is intended for @deepseek-ai/dsh 0.1.0-rc.7 and versions with the same plugin API.
  5. Repository independence: The standalone repository only contains the plugin itself; EAC preset migration and desktop host integration are still maintained by the EAC main project.

Summary

dsh-compact reduces the complexity of maintaining long conversations by automatically generating summaries when context usage approaches the limit or by performing bounded recovery when overflow occurs. For Agent scenarios that require long-running sessions or frequent tool calls, this plugin is a practical tool for maintaining conversation coherence.