AI Agent Hub
Back to plugins
⚙️

dsh-loop-breaker

Workflow Updated 2026.09.16

Run the following command in DeepSeek Harness:

dsh plugin install CHIP-PHILO-GH/dsh-loop-breaker

Paste the following prompt into your AI chat to install this plugin:

Run dsh plugin install CHIP-PHILO-GH/dsh-loop-breaker in the DeepSeek Harness terminal to install this plugin; the source repository is available at https://github.com/CHIP-PHILO-GH/dsh-loop-breaker .

About this plugin

When running long-horizon agent tasks with DSH on DeepSeek flash, the worst failure is not a wrong answer but a degeneration loop: the reasoning chain repeats the same tiny fragment over and over, burning tokens at output speed for minutes without producing anything useful. Existing turn-boundary detectors can stop the loop from spreading to the next turn, but they cannot rescue the one currently burning - the tokens are already spent and the user is left waiting.

dsh-loop-breaker hooks into the DSH llm/stream waterfall events and performs heuristic checks on every chunk as it arrives. The moment a repetition pattern is detected it aborts in place: the underlying HTTP request is cancelled, token billing stops, and a recovery prompt is injected so the model re-answers within the same turn - the user still gets a complete response. Five detection rules cover the real-world degeneration shapes, including tight-period loops, character-set collapse, and short-phrase redundancy. If a tool-call block is still open the abort is deferred to avoid executing half-formed JSON arguments. Before anything is written back to session history, an L0 sanitizer replaces the repeated garbage with a placeholder, preventing it from becoming a prior that triggers the same degeneration on the next generation.

Built for developers who run long-horizon agents on DSH with DeepSeek flash and keep hitting repetition loops. If you only need the detection logic without DSH, the zero-dependency core sub-package can be integrated directly. One caveat: batch code or documents with high structural similarity (for example 40 handlers that differ only by function name) are statistically indistinguishable from degeneration loops - no threshold can separate them, so raise the thresholds or disable the plugin for such outputs.

Use Cases

  • DeepSeek flash agent tasks repeatedly outputting the same fragment and burning tokens at output speed
  • Aborting streaming generation mid-flight the moment degeneration is detected and injecting a recovery prompt
  • Preventing repeated garbage from polluting session history and triggering the same loop on the next generation

Best For

  • Developers running long-horizon agents on DSH with DeepSeek flash
  • Teams whose token budget is repeatedly drained by model repetition loops
  • Integrators who only need the zero-dependency detection core without a full DSH installation