Preface¶
When running long tasks in DeepSeek Harness (DSH), the agent loop itself does not regulate two types of anomalies: the model may “stop after thinking”—finishing reasoning normally but ending the turn without body content or tool calls; or it may enter an inference dead loop—repeatedly spinning, with a single step accumulating an enormous number of reasoning blocks and characters, lasting for minutes. These two situations become more common when paired with DeepSeek V4 Flash and reasoningEffort: max. The community plugin dsh-run-guard addresses both ends: the streaming call and the turn lifecycle. The guard (brake) intercepts dead loops, and the continue (throttle) automatically resumes under reasonable conditions, sharing the per-turn retry budget with upstream error recovery. The following introduces its positioning, capabilities, and installation/configuration methods.
What Is This¶
dsh-run-guard is a plugin package in the DSH ecosystem, presented as PrismLean in the community directory; source code and documentation are available at the GitHub repository (the release installation in the README points to the Dis2017/dsh-run-guard tag). The plugin requires host dsh 0.2.0-rc.2 or above (peerDependencies are validated at installation and startup, and version mismatches will be rejected or require an exact-version exemption). Licensed under MIT.
In one sentence: Agent run rhythm guard—two sides of one coin, preventing “can’t stop” and “won’t work” during long tasks.
Core Features¶
The capabilities listed in the documentation are as follows. The brake and throttle share state awareness, designed so they don’t misfire each other: when guard ends a turn with an error, continue won’t mistakenly push on the completed path; if a turn launched by continue enters another dead loop, guard will still intercept.
| Feature | Direction | Description |
|---|---|---|
| guard | Intercept inference dead loops | Listens to llm/stream, sliding window repetition rate + hard limits; dead loops are interrupted within approximately 1–2 seconds (instead of spinning for minutes), with a default of 2 automatic retries per turn after interruption (configurable), and if it still fails, stops with a Chinese explanation |
| recovery | Upstream failure retry | Automatically retries transient errors like PI_AI_ERROR (extensible whitelist), sharing the per-turn limit with guard |
| continue | Prevent premature halt | Automatically resumes after a turn ends normally: injects state when there are unfinished todos; when there are no todos but the model “stops after thinking,” injects a concise prompt to resume |
| pause_work | Manual pause | The model can call pause_work to proactively pause, and both automatic logic paths will not continue |
Hooked extension points include: llm/stream (guard), agent/request-error (recovery), session/event and systemPrompt.context (continue), tools.register (pause_work), plugins.row.config (Web configuration card, key is dsh-run-guard#run-guard).
Installation and Activation¶
The GitHub release installation command recommended by the official README is as follows (do not assemble owner/repo yourself):
dsh plugin --profile web add "github:Dis2017/dsh-run-guard#v0.2.1"
After dsh plugin add detects the dsh.bundle inside the package, it will automatically mount it into the profile’s bundles list.
Verification steps:
- Restart the GUI (or wait for dsh-hmr to complete configuration reload).
- Open Settings → Plugins and confirm
dsh-run-guardis Mounted / Enabled. - Expand the bundle’s run-guard row and edit the master switch, Guard, Continue, etc. in the configuration page; after saving, dsh writes back the profile patch and reloads the plugin, no process restart needed.
Starting from dsh 0.2.0-rc.2, the configuration entry on the Plugins page is provided by the client component registered by the plugin, no longer relying on the host to auto-generate the settings page based on schema; only fields marked .volatile() support online editing.
For local development, you can mount via absolute path (modify ~/.dsh/profiles/web/cordis.patch.yml, point name to lib/index.js), and there is a complete YAML example in the documentation.
Configuration¶
Edit in the Plugins page, parsed by the Cordis Loader according to the plugin’s exported Config schema for the profile patch. All fields and default values are as follows:
| Configuration | Default | Description |
|---|---|---|
enabled |
true |
Master switch |
guard.enabled |
true |
Dead loop interception |
guard.windowChars |
2000 |
Sliding window size (characters) |
guard.substrLen |
32 |
Repeated detection substring length |
guard.repeatRatio |
0.7 |
Window repetition rate threshold (≥ triggers) |
guard.checkEvery |
50 |
Check once every N blocks |
guard.maxBlocks |
10000 |
Hard limit on reasoning block count per call |
guard.maxChars |
500000 |
Hard limit on reasoning character count per call |
guard.maxGuardRetries |
2 |
Automatic retry limit per turn after interruption (0 disables) |
guard.autoRetryErrors |
["PI_AI_ERROR"] |
Whitelist of additional automatic retry error codes |
continue.enabled |
true |
Auto continue |
continue.maxAutoFollowups |
3 |
Continuous no-output resume limit when todos exist |
No additional API is needed for normal use: dead loops are quickly interrupted and retried (events visible in the interface); after “stop after thinking,” a resume prompt is received. To pause, let the model call pause_work.
Use Cases and Notes¶
Who it’s for: Users running long-chain agents on the DSH Web profile with high reasoning configurations, who have encountered dead loops or turns ending prematurely leaving unfinished tasks.
Permissions and Security: The plugin runs with the same privileges as the current dsh process. Before installation, read the source code and the MIT license, and confirm the release source. The DSH community directory (e.g., SkillHub entry) is an independent site, with no official affiliation with DeepSeek / 幻方 (Huanfang), and is not an official app store.
Version and Dependencies: @deepseek-ai/* must be peerDependencies (host singleton); if a second copy of @deepseek-ai/dsh-tools appears at the top level of the profile, it may trigger Cannot read properties of undefined (reading 'prepare'), and you need to clean up duplicate installations according to the README.
Existing Sessions: Giant dead-loop reasoning produced before installing guard may slow down the GUI; guard only guarantees that no more will be produced afterward. The incorrect llm/retry usage from the 0.1.x era may cause session format validation failures; after upgrading the plugin, new interruptions no longer damage logs, and already damaged sessions need manual correction or archiving (the README provides zstd + grep diagnostic commands).
Conclusion¶
Under DSH’s “everything is a plugin” philosophy, dsh-run-guard uses guard, recovery, continue, and pause_work to make “can’t stop” and “stops after thinking” in long tasks configurable and observable behaviors. For installation and details, see the community directory page PrismLean/dsh-run-guard and the GitHub repository.