Introduction

When building agents with DeepSeek Harness (DSH), models can easily fall into loops that repeatedly invoke the same tool (for example, continuously retrying a 404 API, or repeatedly sending the same read command). This not only wastes tokens but may also trigger rate limiting. To avoid this, DSH needs to block such calls.

Plugin Introduction

dsh-repeat-tool-breaker is a synchronous plugin for DeepSeek Harness (DSH). It registers a ctx.tools.guard gate to perform semantic fingerprint detection on an agent’s tool calls within a sliding window. Once repeated invocations or consecutive failures are detected, it triggers a warning, requests a summary, and blocks the call when a threshold is reached, thereby forcing the model to change its strategy.

Core Features

  1. Semantic Fingerprint Detection: The plugin does not rely on exact identical bytes, but matches based on semantic fingerprints. Supported fingerprint types include:
    • exact: Exactly identical tool invocations.
    • cmd: Command-level fingerprints.
    • net: Network-level fingerprints (such as paths after hostname folding).
    • host: Host-level fingerprints.
    • sink: Data flow fingerprints.
  2. Failure Tracking Track: In addition to detecting repeated invocations, the plugin also tracks consecutive failures. If a fingerprint fails consecutively, it triggers a prompt on the third occurrence and a block on the fifth.
  3. HTTP Request Handling: The plugin rejects HTTP requests in Shell environments and redirects the model to use the web_fetch_file tool to fetch the page and return the path.
  4. Gate Mechanism: This is a synchronous gate; once triggered, the invocation is not executed, and the model receives error feedback.

Installation and Enablement

Before installing, ensure your DSH version meets the requirements. This plugin supports dsh >= 0.1.7 (Session format 4) and dsh 0.2.0 series versions.

If you are using DSH 0.1.5, install the specific version:

dsh plugin install dsh-repeat-tool-breaker@0.7

For DSH 0.1.7 and 0.2.0 (rc.1 up to but not including 0.2.1), use the latest version (currently the 0.8.x series):

dsh plugin install dsh-repeat-tool-breaker

Typical Usage

After installation, the plugin’s gate logic is enabled by default. When a call is blocked, the model receives an isError result that starts with REPEAT_TOOL_BLOCKED and contains references to previous invocations along with suggested alternatives.

At the configuration level, the behavior after a block can be controlled via the onLimit parameter:
* onLimit: ask (default): When a block occurs, ask the operator whether to allow this invocation (i.e., grant a one-time exemption).
* onLimit: deny: Deny directly without asking.

Use Cases and Considerations

  1. Version Compatibility: This plugin depends on DSH Session format 4, and the 0.1.7 release refactored the settings API. This means configuration pages cannot be registered simultaneously for both the 0.1.7 and 0.1.5 generations in a single build. If you are using 0.1.5, you will only get the functional logic and cannot use the settings card.
  2. Collaboration with Official Plugins: The official plugin @deepseek-ai/dsh-repeat-tool-reminder can coexist with dsh-repeat-tool-breaker. The Reminder is responsible for early warnings (at 3/5/8 repetitions), while the Breaker is responsible for later blocking (at 12 repetitions).
  3. Runtime Permissions: The plugin runs with the permissions of the current DSH process. Before installing, it is recommended to review its source code and license (MIT).

Conclusion

dsh-repeat-tool-breaker provides a hard safeguard for DSH agents against infinite loops by introducing semantic fingerprints and a dual-track detection mechanism. It evolves from simple repetition counting to analyzing failure behavior, effectively identifying a model’s stubborn fixation on a particular resource.

View Catalog Page
View GitHub Source Code