dsh-compaction-route: Configuring Fallback Models for DSH Compaction Tasks

The compaction engine in DSH (DeepSeek Harness) lacks a built-in failover mechanism when a conversation compaction summarizer is selected in the Web settings page. When a summarization call is rejected or fails due to context limits, the entire compaction process errors out immediately without attempting alternative models. Furthermore, DSH’s fixed character estimation (chars/4) deviates from the actual tokenization results of different models. This can lead to a situation where history appropriate for the chat model exceeds the input limit for the selected summarizer.

dsh-compaction-route aims to address these issues. It is a DeepSeek Harness plugin that allows you to specify a fallback model for the compaction summarizer in the settings page. It automatically switches to this model when the primary model cannot handle the history.

Core Features

This plugin only takes effect for requests where purpose === "compaction", intercepting DSH’s llm/stream pipeline. Key capabilities include:

  1. Target Rewriting: Rewrites the request’s target to the configured “Primary Model”.
  2. Terminal Error Retry: If the primary model call ends with a terminal error block, automatically attempts the “Fallback Model” on the same request.
  3. Oversized History Fallback: Provides a safety net for replayed history that may exceed input limits.
  4. Model Selection: Reads the list of available models from the installed profile configuration.

Installation and Activation

The installation process requires no build steps, and the application does not need to be restarted after the plugin is mounted.

Web UI Installation

  1. Open the settings page.
  2. Navigate to Plugins.
  3. Click Add plugin.
  4. Enter the plugin spec in the input field:
    github:643048695/dsh-compaction-route
  1. Follow the prompts to enable the plugin. The inserted line ID after installation is compaction-route, which also serves as the namespace for the configuration page.

CLI Installation

dsh plugin --profile <profile> add github:643048695/dsh-compaction-route

Configuration

After installation, go to Settings → Plugins → dsh-compaction-route → Configuration to configure it.

Setting Description
Enable routing Turns on the routing feature. When disabled, the engine behaves as if the plugin were not installed.
Primary model The summarizer model attempted first.
Fallback model Attempted only when the primary model returns a terminal error. Disabled if left blank.
Reasoning effort The reasoning effort for the compaction call; uses the provider’s default if left blank.

The options in the dropdown menu originate from the llm-pi-ai configuration namespace and only display models installed in the current profile. The settings are volatile, meaning changes take effect only for the next compaction without requiring a restart.

Prerequisite for selecting a fallback: The effective window of the fallback model must be larger than that of the primary model. If the window size is the same or smaller, selecting a fallback model will not solve the problem, and the configuration card will display a warning.

How it Works

The plugin intercepts the llm/stream watermark and executes the following logic for compaction tasks:

  1. If the request’s purpose is not "compaction", it passes through directly without any modifications.
  2. Rewrite the target to the configured Primary model.
  3. If Primary succeeds, return its data stream.
  4. If Primary ends with a terminal error block, re-enter ctx.llm.stream() and retry using the Fallback model.
  5. Return the first successful result, or the result of the last attempt.

Note: The plugin tracks the call objects it creates via a WeakSet to prevent the retry logic from being intercepted again.

Notes and Compatibility

  • Retry Scope: Retries only occur on terminal error blocks. If a non-terminal error occurs (e.g., an intermediate state exception), it is handled according to original behavior, and the fallback is not triggered.
  • Cancellation Priority: If the request is cancelled, retry is not triggered.
  • Compaction Only: The plugin only modifies requests with purpose === "compaction"; chat turns, sub-agents, and other tasks are unaffected.
  • Logging: The engine’s own events still log its configured target (summarizationProvider/summarizationModel) rather than the plugin’s actual override target. For log consistency, the target in engine settings should be set to the same primary model as the plugin.
  • Compatible Versions: Compatible with @deepseek-ai/dsh 0.1.7-rc.2 and the same-node 0.1.7 line.

Summary

dsh-compaction-route solves the single point of failure in the DSH compaction engine by adding a layer of routing logic to the compaction pipeline. When facing compaction failures caused by long conversation history that the primary model cannot handle, configuring a fallback model with a larger context window is an effective solution.

  • GitHub Repository: https://github.com/643048695/dsh-compaction-route
  • Community Directory: https://www.skillhub.cn/plugins/643048695/dsh-compaction-route
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye