Introduction¶
DeepSeek Harness (DSH) adopts a plugin-based architecture, which facilitates functional extensions. However, in practical use, as conversation turns accumulate, verbose tool outputs, large code blocks, or XML structures in the history quickly consume the context window, leading to excessive Token consumption.
dsh-shake is a third-party Host plugin designed to manually reduce context usage. It reclaims space by replacing old tool outputs and large code/XML blocks with short placeholders, and supports restoring the original text via the shake_read tool when needed.
Core Features¶
The plugin primarily offers the following capabilities:
* Placeholder Replacement: Automatically identifies and replaces eligible historical text with short placeholders.
* Context Protection: Protects the most recent 4000 tokens of history by default to prevent premature clearing of critical context.
* Content Recovery: Reads replaced original text fragments via the shake_read tool.
* Flexible Configuration: Customizable cleanup thresholds (e.g., minimum code block length).
Installation and Enabling¶
Before installation, ensure that the DSH Web Profile has been initialized in your environment.
- Check the DSH version:
dsh --version
- Install the plugin:
dsh plugin --profile web add dsh-shake@latest --ignore-scripts
- Check the configuration output to confirm that
dsh-shakeis included. - Restart the Web service to apply the configuration:
dsh web
Usage¶
The plugin usage consists of two steps: “Scheduling Cleanup” and “Restoring Text”.
Scheduling Cleanup¶
- Wait for the current session to be idle.
- In the Web interface message input box, send:
/shake
- Once confirmed by the system, the cleanup request is saved. The model is not invoked immediately, nor is the context reduced instantly.
- Send the next normal message. DSH executes the cleanup and replaces eligible text before the request is sent to the model.
Canceling Cleanup¶
If you need to cancel a pending cleanup request:
/shake cancel
Note: Cancellation applies only to unexecuted requests; executed replacements cannot be undone.
Cleanup Scope¶
The plugin defaults to traversing backward from the latest history, protecting the most recent 4000 tokens. Messages beyond this boundary are preserved in full.
Within this boundary, only content meeting the following conditions will be replaced:
- Tool Results: The total text of a single result must reach 1000 tokens or more.
- Assistant Replies: A single fenced code block or XML block must reach 400 tokens or more.
The following content will NOT be cleaned up:
* User, system, and developer messages.
* Error tool results.
* Messages containing images, thinking, or non-text blocks.
* Regular long paragraph text.
Configuration Parameters¶
The default configuration meets most requirements. To adjust, add a configuration override in the corresponding Profile’s cordis.patch.yml (do not add a second plugin instance):
- id: dsh-shake
config:
protectedTokens: 4000 # 保护的最近历史 token 数
toolTextMinTokens: 1000 # 工具结果清理的最小 token 数
assistantBlockMinTokens: 400 # 代码块清理的最小 token 数
readDefaultLimit: 2048 # shake_read 默认读取页大小(Unicode code points)
readMaxLimit: 4096 # shake_read 最大读取页大小
Configuration takes effect after restarting DSH.
Reading Original Text¶
Replaced text retains a placeholder containing a ref. The model can retrieve the original content by calling the shake_read tool.
Tool Parameters:
* ref: The full reference string copied from the placeholder.
* offset: The starting offset for the current page, beginning from 0.
* limit: The number of characters to read per page, not exceeding the configured readMaxLimit.
Response Fields:
* text: The text content of the current page.
* offset: The current offset.
* totalLength: The total length of the fragment.
* nextOffset: The starting offset for the next page.
* done: A boolean indicating whether reading is complete.
Note:
* shake_read can only read fragments that were actually removed.
* Offsets and lengths are counted in Unicode code points, not bytes or UTF-16 length.
* Parameters in non-ref formats, such as file paths, are not accepted.
Notes¶
- Third-party Plugin: dsh-shake is maintained by the community and is not an official DeepSeek product.
- No Summary Generation: The plugin does not generate summaries or delete original logs; it only performs placeholder replacement.
- Execution Timing:
/shakeonly schedules cleanup; actual replacement occurs before the next model request. - Permission Restrictions: The plugin runs with the current DSH process permissions. It is recommended to review the source code and license before installation.
Summary¶
dsh-shake provides a flexible and controllable way to manage context size in long conversations. It is a practical tool for developers who need to retain specific long code snippets or tool logs while compressing history. For more details, please refer to the GitHub repository.