Introduction

DeepSeek Harness (DSH) occasionally encounters a situation during long-chain reasoning where the model has already completed its thinking but gets stuck and idles repeatedly in the “preparing output” stage. This silent hang consumes a large amount of compute and characters until the user manually stops it.

dsh-reasoning-loop-guard is attached to the llm/stream hook and evaluates five criteria by measuring the streamed reasoning text. Once loop characteristics are detected, it immediately stops pulling data from upstream and returns a termination block, converting a silent failure into a visible error message.

Plugin Overview

Name: himi-li/dsh-reasoning-loop-guard
Owner: himi-li
Category: Model reasoning
License: MIT

This plugin focuses on detecting and preemptively interrupting reasoning repetition in DSH. It provides a fire journal and a reasoning_loop_log tool, and supports recovery functionality and a GUI panel.

Installation

This package has not yet been published to npm and must be installed from the GitHub source. DSH is isolated by profile: the desktop edition uses desktop, and the web edition uses web.

  1. Desktop edition: The built-in command runtime of DSH Desktop must be used, and the application must be started first for initialization.
  2. Web edition: Any dsh CLI can be used. If the web profile does not exist, it is automatically initialized.
# 桌面版
dsh plugin --profile desktop add github:himi-li/dsh-reasoning-loop-guard

# 网页版
dsh plugin --profile web add github:himi-li/dsh-reasoning-loop-guard

After installation, restart the DSH process rather than merely refreshing the page.

Configuration and Enablement

After installation, enable and configure the parameters in the profile’s cordis.patch.yml:

- insert:
    - id: reasoning-loop-guard
      name: dsh-reasoning-loop-guard
      config:
        enabled: true
        # 判据阈值配置
        minUnits: 4                # periodic-run:连续重复单元数
        kgramThreshold: 12         # kgram-repeat:尾部 k-gram 的出现次数
        lineCount: 3               # line-repeat:重复行出现次数
        lineShare: 0.1             # line-repeat:重复行占窗口的最低比例
        blockCount: 4              # block-repeat:同一块的重复次数
        fillerRun: 400             # filler-run:末尾连续装饰字符数
        minChars: 800              # 低于这么多字符不做判定
        every: 200                 # 每 N 个字符评估一次
        failureCode: REASONING_LOOP_GUARD

        # 日志配置
        journal: true
        journalPath: ""            # 默认:$DSH_HOME/dsh-reasoning-loop-guard/fires.jsonl
        journalMaxBytes: 524288
        journalPreviewChars: 120
        logTool: true              # 注册 reasoning_loop_log 工具

How It Works

The plugin evaluates five criteria on a rolling buffer every every characters:

  1. periodic-run: The buffer’s tail contains ≥ minUnits consecutive identical units.
  2. block-repeat: The same blockMin-character block appears ≥ blockCount times within the window.
  3. line-repeat: The same prose line (≥ lineMin characters) appears ≥ lineCount times and accounts for ≥ lineShare of the window.
  4. kgram-repeat: The final kgram characters appear ≥ kgramThreshold times within the window.
  5. filler-run: The raw text’s tail has ≥ fillerRun consecutive decorative characters.

The five criteria are disjunctive; if any one is hit, interruption is triggered. The plugin only measures reasoning-delta and does not measure text-delta or block-end, to avoid falsely interrupting normal long outputs (such as tables or code).

Features

  • Detection and interruption: Detects reasoning loops and cuts them off early, returning a termination block.
  • Zero-dependency Cordis plugin: Runs independently.
  • Fire journal: A JSONL file that records trigger events.
  • Tool support: Registers the reasoning_loop_log tool.
  • Recovery: Provides recovery capability after interruption.
  • GUI panel: Provides a visual interface.

Notes

  • This plugin does not measure text-delta and does not measure block-end.
  • It does not report code lines, markers, or diff lines identified as code.
  • Decorative elements (such as divider lines) are not treated as repetition, but continuous output of decorative elements triggers the fallback rule.
  • The desktop edition must use the built-in command runtime of DSH Desktop.