filantropo17/dsh-llm-repetition-guard ↗★ 0
dsh-llm-repetition-guard
Degenerate-output repetition guard for the DeepSeek Harness
安装
此插件尚未提供可验证的 bundle,或兼容性检查未通过。请先阅读仓库说明。 阅读完整 README ↗
说明文档
阅读完整 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.