返回目录
模型与 MCP 插件

dsh-loop-recover

terry2010/dsh-loop-recover

A guard for DeepSeek Harness: stops model repeat loops mid-stream, prunes and compacts context, then resumes the task.

Stars
1
Forks
0
Issues
0
更新
5 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:terry2010/dsh-loop-recover

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-loop-recover

dsh-loop-recover

Detects model dead loops and auto-rescues — the task resumes in place.

npm version GitHub stars MIT license GUI configurable
English · 中文


What It Does

Small local models (Ornith, some Qwen variants, etc.) can collapse into literal token loops (ssssss...) or semantic analysis loops — re-reasoning the same paragraphs forever. Plain loop guards just cut and stop; the task dies.

dsh-loop-recover breaks the full rescue chain:

  • Detect — 5-layer detector: periodic, n-gram, anchor, char-run, sentence-pool + intent-level tool-query tracking
  • Prune — cuts the repeated suffix mid-stream, leaves a one-line marker so the model knows something was removed
  • Compact — replaces the poisoned context with a checkpoint summary (v4 compaction/* transaction) so the model can't replay the same reasoning
  • Resume — auto-followups the same task with fresh sampling params — no new session, no restart

All inside one agent loop — the model keeps working after rescue.

Install

GUI (recommended)

Open Plugins → Add plugin, search dsh-loop-recover, click Install.

CLI

dsh plugin --profile desktop add dsh-loop-recover
# then restart the app

Configuration

Everything is editable on the plugin page — no YAML needed. 32 fields grouped: Basics / Rescue / Resume / Intent / Detection / Detector (Advanced).

Group Key fields
Basics mode (rescue/cut/observe), watch, language, keepLanguage, marker, debugLog
Rescue maxConsecutiveRescues, maxTotalRescues (lifetime cap, never resets), compactOnRescue, stallCalls
Resume retryTemperature, retryReasoningEffort, retryRequests
Intent intentEnabled, intentNoveltyThreshold, intentConfirmCount

Modes — rescue (cut+prune+compact+resume, default), cut (prune only, no resume), observe (log only, zero intervention — use this to evaluate thresholds on your workload first).

Why not other loop plugins

Different tools solve different problems — don't stack them:

Plugin What it does Conflict
dsh-agent-loop-guard Cuts at loop detection, stops turn Both wrap llm/stream → double-cut, confused state
dsh-client-auto-continue Resumes after interruption Triggers extra resume → two conflicting continuation commands
dsh-session-shift Context-pressure compaction → new session Overlapping rescue → one compacts while the other shifts

Disable them when using this plugin.

How it works

llm/stream (agent calls only)
  ↓ StreamLoopDetector — watches reasoning & text blocks
loop hit → cut repeated suffix → rewrite block-end → finish: stop
  ↓ commitLoopCompaction — v4 transaction, old context → checkpoint
  ↓ followup() — resume same task, fresh sampling params

Non-agent requests (title/summary generation) pass through untouched.

Reasoning blocks use relaxed thresholds (sentence-pool ≥8, n-gram ≥4): template verdicts in methodical enumerations are normal style, not loops; text blocks keep the defaults.

Development

npm test        # 84 unit + integration tests
npm run check   # plugin load smoke

License

MIT · NOTICE for upstream attributions (dsh-compaction helpers adapted).

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度高

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: llm、deepseek-harness。