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:

  1. 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.

  2. 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.

  3. Zero core modifications
    The plugin is fully implemented based on Cordis lifecycle hooks and requires no modifications to the DeepSeek Harness core code.

  4. 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.

  5. 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.

  1. Environment check
    Ensure Node.js 20 or later is installed on the system.
    Ensure DeepSeek Harness and its core dependencies are installed.

  2. 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.

  3. 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.

  1. 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)
  2. 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.
  3. 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.

  1. 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.

  2. Configuration adjustment
    In production environments, it is recommended to adjust maxCallsPerRepeatGroup and maxToolAttemptsPerTurn appropriately 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.