DSH agents in long-conversation scenarios often face context-window limits or API call costs. dsh-force-compact runs Qwen3.8‑27B on local llama.cpp and applies compaction logic directly to the conversation history, providing a “large-window” experience while keeping the resident prompt small and fast.

Core Positioning

This is a DSH Cordis plugin designed to keep agents running by “shrinking history” rather than relying solely on an ultra-large context window. It runs locally by default: data stays on the machine, with no API costs.

How It Works

The plugin provides dual-engine support under the single interface resolveCompaction and switches automatically:

  • Official engine: Preferred when the compaction service can be resolved in the agent domain; it delegates to compaction/basic.
  • Built-in engine: Used as a fallback. It takes over when the official service is unavailable (for example, if a standard preset isolates that service). It directly operates on ctx.sessions / ctx.llm.stream / ctx.tokenMeter, reuses the official event vocabulary, and ensures safe replay.

Trigger Mechanisms

Compaction is triggered through the following paths:

  1. Pre-request guard (agent/pre-step): Reads the session’s projectedTokens (the number displayed in the bottom-right corner of the UI). When autoThresholdTokens is reached, the current request is rejected and compaction is performed instead, retaining the latest retainLatestTokens. If the threshold is not reached, the request is allowed to proceed.
  2. Turn end/idle (agent/status → idle): When the agent is idle, compaction is triggered via compactNow (requires turnEndForceCompactionEnabled to be enabled).
  3. Manual command (/force-compact): If the agent is idle, compaction runs immediately; if the agent is busy, a local flag is set to run it at the next model step.
  4. Session flush (session/flush): Triggers compaction at a persistence checkpoint.

All paths ultimately converge at the boundary of “writing the compaction result back to the session,” and then trigger a LiveUI status update.

Thinking Control

By default, disableThinking: true is set, and this control applies only to compaction calls.

  • Compaction calls: Carry reasoningEffort:'off' (or llama.cpp’s reasoning_effort:"none") to force thinking off.
  • Other requests: The machine’s LlmCallConfig remains unchanged and is unaffected.
  • Compatibility: If the model does not support the off level, the plugin probes routing capabilities and automatically downgrades to the lowest supported level (such as low) instead of throwing an error. For models that do not support reasoning at all, the field is omitted.

LiveUI Status

The plugin sends real-time status text via LiveUI:
* [强制压缩中>>>]: Before compaction is submitted.
* [压缩完成!]: After compaction completes.

Dependencies and Installation

The plugin runs as a DSH Cordis plugin and requires the following peer dependencies:

{
  "@deepseek-ai/cordis": ">=4.0.4",
  "@deepseek-ai/dsh-agent": ">=0.2.0-rc.1",
  "@deepseek-ai/dsh-compaction": ">=0.2.0-rc.1",
  "@deepseek-ai/dsh-commands": ">=0.2.0-rc.1",
  "@deepseek-ai/dsh-client-store": ">=0.2.0-rc.1",
  "@deepseek-ai/dsh-client-ui-primitives": ">=0.2.0-rc.1",
  "@deepseek-ai/dsh-client-ui-settings": ">=0.2.0-rc.1",
  "@deepseek-ai/dsh-client-locale": ">=0.2.0-rc.1",
  "@deepseek-ai/dsh-llm": ">=0.2.0-rc.1",
  "@deepseek-ai/dsh-session": ">=0.2.0-rc.1",
  "@deepseek-ai/dsh-session-projection": ">=0.2.0-rc.1",
  "@deepseek-ai/dsh-settings": ">=0.2.0-rc.1",
  "@deepseek-ai/dsh-token-meter": ">=0.2.0-rc.1",
  "@deepseek-ai/schemastery": ">=3.18.4"
}

Note: Installation is typically done through a package manager or the DSH plugin mechanism. For details, refer to the plugin’s exports and files fields in package.json (such as index.js, src/, web/, cordis.patch.yml, and others).

Use Cases

Suitable for scenarios that require running large models locally, are sensitive to context-window limits, and want zero API costs. Because the plugin runs under the current DSH process permissions, it is recommended to review the source code and license before installation.