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:
- 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 thanduplicateLimittimes within a sliding window, the call is rejected. - Total call limit: The plugin sets a
maxCallsPerAgentlimit for each Agent object. This helps catch looping patterns where parameters change slightly to bypass duplicate detection. - 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.
- 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¶
- Configuration location: Configuration must be done through
cordis.patch.yml. Directly configuring thecircuit-breakernamespace insettings.yamlhas no effect. - Tools with dynamic arguments: For tools such as
bashthat have free-text arguments (such asdescription) whose values change dynamically, if you want duplicate detection, you must setignoreArgsin the configuration to ignore those arguments. - Restart requirement: After changing the configuration, always restart the Profile.
- 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.