filantropo17/dsh-llm-repetition-guard ↗★ 0
dsh-llm-repetition-guard
Degenerate-output repetition guard for the DeepSeek Harness
AI Analysis
核心用途是检测并拦截大模型的重复退化输出。适合需要提高生成文本质量、防止模型陷入死循环的用户。需在提供商配置中添加对应重试状态码。
Install
This plugin has no verified bundle, or compatibility checks failed. Read the repository notes first. Read the full README ↗
README
Read the full README ↗Usage
Install the package:
npm install dsh-llm-repetition-guard
Mount the plugin beside @deepseek-ai/dsh-llm-retry and add DEGENERATE_OUTPUT to the provider's retryableCodes:
- name: '@deepseek-ai/dsh-llm-deepseek'
config:
retryPolicy:
mode: normal
maxRetries: 2
retryableCodes: ['EMPTY_RESPONSE', 'DEGENERATE_OUTPUT', 'RATE_LIMIT', 'SERVER', 'TIMEOUT', 'TRANSPORT']
- name: 'dsh-llm-repetition-guard'
config:
minOutputLength: 64
windowChars: 1024
unitLength: 8
maxRepeats: 6
checkReasoning: false
- name: '@deepseek-ai/dsh-llm-retry'
Why the explicit
retryableCodes? The published@deepseek-ai/dsh-llm(through0.1.0-rc.7) does not includeDEGENERATE_OUTPUTin its default retryable set. Without it, the guard still truncates the degenerate stream and fails the request, but the loop treats the failure as terminal and the turn ends with an error. Add the code to make retry effective. A harness checkout that already carries the code inDEFAULT_RETRYABLE_CODESmay omit the list.
The plugin has no other configuration. Thresholds are optional and default conservatively:
| Key | Default | Meaning |
|---|---|---|
minOutputLength | 64 | Minimum characters a block accumulates before detection starts. |
windowChars | 1024 | Sliding-window characters retained per block; must be at least minOutputLength. |
unitLength | 8 | Minimum character length of one repeated unit. |
maxRepeats | 6 | Consecutive occurrences of one unit that trip the guard. |
checkReasoning | false | Also guard reasoning blocks. |
Verifying it works
Send a prompt that makes the model loop (or lower maxRepeats to 2 and use a degenerate output). The session log records the recovery:
- an
llm/retryevent whosefailure.codeisDEGENERATE_OUTPUTand whosefailure.messagenames the repeated unit; - the retried request completes normally and the turn ends
completed.