filantropo17/dsh-llm-repetition-guard0

dsh-llm-repetition-guard

Degenerate-output repetition guard for the DeepSeek Harness

AI 分析

核心用途是检测并拦截大模型的重复退化输出。适合需要提高生成文本质量、防止模型陷入死循环的用户。需在提供商配置中添加对应重试状态码。

パッケージ
dsh-llm-repetition-guard
バージョン
0.1.0
ライセンス
MIT
最終更新
2026/08/19

インストール

検証済み 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 (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.