Introduction¶
DeepSeek Harness (DSH) is a plugin-based framework for large model inference. During development or use, a model may enter a “repetition” state, continuously outputting the same string or paragraph. This not only wastes tokens but also pollutes the session context.
dsh-dupguard is a real-time duplicate output guard plugin for DSH. It detects repeated content in real time within the model generation stream and immediately stops the current generation once the same string has been repeated consecutively up to the threshold.
What is it?¶
Name: zqh260619/dsh-dupguard
Positioning: A model inference plugin that addresses circular repetition in large model outputs.
Core capabilities:
- Real-time monitoring: Detects incrementally during streaming output.
- Precise truncation: If the same string is repeated consecutively 10 or more times in the output (default value), it immediately interrupts the generation stream.
- Compatibility: Supports dual entry-point delivery via DSH dynamic plugins and the npm resident version.
Installation and activation¶
Before installation, ensure the environment meets the following requirements:
- DSH version ≥ 0.1.2-rc.1 (host API lower bound is ≥ 0.1.1-rc.1)
- Node.js version ≥ 20
Run the following command to install the plugin (the example uses the web profile; replace it with your actual profile name):
dsh plugin --profile web add dsh-dupguard
After installation, you must restart DSH for it to take effect, because the host code is loaded only when the process starts.
Criteria for successful installation:
1. A new “Duplicate Guard” section appears in the settings page.
2. The host log contains [dupguard] Effective parameters: … (defer to the log).
Core features¶
Detection mechanism¶
- Incremental detection: Each
text-deltaarrival triggers evaluation, and a match stops immediately. - Repetition patterns: Supports multiple patterns, including single characters, words, strings separated by spaces/newlines, and line-by-line repetition.
Code region relaxation¶
By default, the detection threshold for code regions (including fenced code blocks, inline code, and indented code blocks) is relaxed to 3 times the default value. This prevents character repetition in normal code writing or test fixtures from being misidentified.
Reasoning guard¶
Detection of reasoning (thinking) text is enabled by default. If the model enters a loop during reasoning, it will also be truncated immediately. It can be disabled in settings by using monitorReasoning: false.
Truncation notification¶
The plugin provides global notifications. Regardless of which session the user currently has open, a notification pops up when truncation occurs, showing the repeated string and repetition count, and provides options to “Continue” or “Do not send”.
Configuration and settings¶
Parameters can be adjusted from the settings page. Changes take effect without a restart; the configuration is written back to cordis.patch.yml and hot-read by the host.
Default configuration¶
- Trigger threshold: Default consecutive repetition ≥ 10 times.
- Code multiplier: The code region multiplier defaults to 3.
Detection scope¶
- Ignore whitelist: Supports ignoring specific characters (such as the Markdown table separators
-|) and specific string fragments. - Tool arguments: Tool call arguments are not detected by default (
monitorToolArguments: false).
Tiered table mode (experimental)¶
The settings page supports tiered table mode, limited to 1-16 rows, and is used to set different repetition-count thresholds dynamically based on output unit length.
Notes and limitations¶
- Version dependency: The plugin depends on DSH >= 0.1.2-rc.1 and Node >= 20.
- Known issue:
fixStandingMountConflictis enabled by default, but testing has revealed a defect in DSH 0.1.1-rc.1 and 0.1.2-rc.1. - Notification mechanism: The truncation notification is a global notification and is unrelated to the currently open session.
- Configuration evolution: Starting from version 1.0.0, configuration keys only increase and are never removed; the allowed value ranges for configuration items only expand and never shrink.
- Experimental feature:
advancedThresholdFileis an experimental feature.
Summary¶
By adding a layer of real-time detection to DSH streaming output, dsh-dupguard effectively prevents models from falling into meaningless repetitive loops. Its default relaxed code detection policy and global notification mechanism make it highly practical in both development debugging and production environments.