filantropo17/dsh-llm-repetition-guard0

dsh-llm-repetition-guard

Degenerate-output repetition guard for the DeepSeek Harness

包名
dsh-llm-repetition-guard
版本
0.1.0
许可证
MIT
最近更新
2026年8月19日

安装

此插件尚未提供可验证的 bundle,或兼容性检查未通过。请先阅读仓库说明。 阅读完整 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 (through 0.1.0-rc.7) does not include DEGENERATE_OUTPUT in 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 in DEFAULT_RETRYABLE_CODES may omit the list.

The plugin has no other configuration. Thresholds are optional and default conservatively:

KeyDefaultMeaning
minOutputLength64Minimum characters a block accumulates before detection starts.
windowChars1024Sliding-window characters retained per block; must be at least minOutputLength.
unitLength8Minimum character length of one repeated unit.
maxRepeats6Consecutive occurrences of one unit that trip the guard.
checkReasoningfalseAlso 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/retry event whose failure.code is DEGENERATE_OUTPUT and whose failure.message names the repeated unit;
  • the retried request completes normally and the turn ends completed.