- Home
- Plugins
- Sessions & Messages
- dsh-loop-recover
dsh-loop-recover
terry2010/dsh-loop-recover
Loop guard for DeepSeek Harness: detects and stops repeated output mid-stream, prunes and compacts context, then automatically resumes the task without a restart.
Install
dsh plugin --profile web add github:terry2010/dsh-loop-recoverREADME
dsh-loop-recover
Detects model dead loops and auto-rescues — the task resumes in place.
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, 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.
Development
npm test # 66 unit + integration tests
npm run check # plugin load smoke
License
MIT · NOTICE for upstream attributions (dsh-compaction helpers adapted).
Related plugins
dsh-web-ui (dsh-chat-recovery)
zhu1090093659/dsh-web-ui
billion-context
ranxianglei/billion-context
dsh-synapse
liangmianya/dsh-synapse
dsh-archive-manager
michengai/dsh-archive-manager