Introduction

When running agents with DeepSeek Harness (DSH), the model may fall into an infinite loop, repeatedly executing exactly the same tool call and unable to be corrected by instructions. This type of loop occurs outside the model’s logic, so ordinary prompts cannot prevent it. dsh-circuit-breaker is a Loop Guard plugin designed to address this issue.

Core Positioning

This plugin belongs to the admin-security category, is maintained by pricklywiggles, and is licensed under the MIT License. It operates outside the model’s logic and uses code-level guards to block runaway looping behavior.

Core Features

The core role of the plugin is to prevent infinite repetition of tool calls. It achieves this through the following mechanisms:

  1. Duplicate call detection: The plugin registers a guard through ctx.tools.guard() to check before each tool execution in the DSH runtime. If the same tool is invoked more than duplicateLimit times within a sliding window, the call is rejected.
  2. Total call limit: The plugin sets a maxCallsPerAgent limit for each Agent object. This helps catch looping patterns where parameters change slightly to bypass duplicate detection.
  3. Rejection and recovery: When a call is rejected, the plugin returns explanatory text telling the model or user what happened, helping the model resume normal operation.
  4. Monotonicity: In the DSH environment, rejections are monotonic, meaning that once a call is rejected by a guard, downstream plugins cannot re-allow that call.

Installation and Activation

Installing this plugin requires DSH CLI commands. The package is a pure ESM module and requires no build step.

dsh plugin --profile web add github:pricklywiggles/dsh-circuit-breaker

After installation, you must restart the corresponding Profile for the changes to take effect.

To pin a specific version, you can use a commit SHA:

dsh plugin --profile web add github:pricklywiggles/dsh-circuit-breaker#<sha>

Configuration

All configuration options have default values. To override the defaults, you cannot configure them in settings.yaml; overrides must be made in the cordis.patch.yml layer.

Example configuration:

- id: circuit-breaker
  config:
    duplicateLimit: 6
    maxCallsPerAgent: 300

Use Cases and Notes

  1. Configuration location: Configuration must be done through cordis.patch.yml. Directly configuring the circuit-breaker namespace in settings.yaml has no effect.
  2. Tools with dynamic arguments: For tools such as bash that have free-text arguments (such as description) whose values change dynamically, if you want duplicate detection, you must set ignoreArgs in the configuration to ignore those arguments.
  3. Restart requirement: After changing the configuration, always restart the Profile.
  4. Irreversibility: Due to the monotonicity of rejections, once a call is blocked, subsequent identical calls in the same session will continue to be rejected.

Summary

dsh-circuit-breaker provides DeepSeek Harness with a way to constrain agent behavior at the code level, effectively preventing resource waste caused by the model getting stuck in local optima.