Introduction¶
During the development of DeepSeek Harness (DSH), autonomous agents may fall into infinite retry loops when encountering tool failures, ambiguous instructions, or hallucinations. For example, repeatedly reading the same directory, editing the same code lines, or continuously repeating the same text in the output stream. Such situations can quickly consume token budgets and API credits without advancing the user’s goal. dsh-agent-loop-guard is a native host runtime plugin designed for DSH, intended to intercept and block such runaway loops and prevent resource waste.
Core Features¶
The plugin implements closed-loop protection through the following mechanisms:
-
Progress-aware tool calling guard
It uses epoch-based state tracking and blocks repeated calls only when no meaningful state change or new evidence is detected. This allows legitimate iterations (such as read ➔ edit ➔ read ➔ edit) to proceed normally and avoids false positives on valid operations. -
Assistant output loop blocker
It detects repeated lines or Markdown blocks in real time within streaming text. When continuously generated content exceeds a threshold, it force-cancels session generation to prevent output runaway. -
Zero core modifications
The plugin is fully implemented based on Cordis lifecycle hooks and requires no modifications to the DeepSeek Harness core code. -
Enterprise privacy and token redaction
The logging system automatically redacts sensitive credentials, such as Bearer tokens, passwords, cookies, and secrets in query parameters, replacing them with[redacted]to prevent sensitive information leakage. -
Native WebUI configuration and telemetry
It provides a native WebUI configuration entry point, supporting plugin settings and telemetry reporting.
Installation and Enablement¶
The plugin runs with the permissions of the current DSH process. Before installing, ensure the environment meets the dependency requirements.
-
Environment check
Ensure Node.js 20 or later is installed on the system.
Ensure DeepSeek Harness and its core dependencies are installed. -
Installation method
Since no direct installation command is provided, install it through the official plugin directory:
Visit the directory URL:https://www.skillhub.cn/plugins/GooDAnDReaDY/dsh-agent-loop-guard
Complete the addition and enablement of the plugin on the directory page. -
Dependency validation
During installation, DSH automatically checks whether the following peer dependencies are satisfied:@deepseek-ai/cordis@deepseek-ai/schemastery@deepseek-ai/dsh-settings
Typical Usage¶
The plugin controls looping behavior through stop words and configuration parameters.
-
Stop words that trigger blocking
During user message analysis, the plugin supports multiple stop words to immediately trigger a refusal to execute:stop,halt,cancelпрекрати(Russian: stop)ответь(Russian: answer)петля(Russian: loop)
-
Default configuration parameters
The plugin ships with a default loop-limiting policy and usually works without modification:- Maximum repeated call count: For the same call group, the default limit is 5 times.
- Maximum tool attempt count: Per conversational turn, the default limit is 64 non-productive tool attempts.
-
Configuration method
All settings can be configured through the WebUI:
Go to the WebUI Settings page -> Select Plugins -> Click Plugin Settings. Adjust the specific loop-blocking thresholds and behavior here.
Use Cases and Notes¶
This plugin is suitable for any scenario that needs to prevent agents from entering infinite loops, especially during long-running tasks or automated script development.
-
Runtime permissions
The plugin runs with the permissions of the current DSH process, meaning it has the same system access capabilities as DSH. Before installing and enabling it, be sure to review the plugin source code and license (MIT) to confirm that its behavior meets your security and compliance requirements. -
Configuration adjustment
In production environments, it is recommended to adjustmaxCallsPerRepeatGroupandmaxToolAttemptsPerTurnappropriately based on task complexity to balance safety and task flexibility.
Conclusion¶
dsh-agent-loop-guard provides a Fail-Closed runtime protection mechanism, helping developers build more stable and controllable DeepSeek Harness agent systems.
- Project directory: https://www.skillhub.cn/plugins/GooDAnDReaDY/dsh-agent-loop-guard
- Source repository: https://github.com/GooDAnDReaDY/dsh-agent-loop-guard