Preface¶
When running agents in DeepSeek Harness (DSH), models sometimes repeatedly call the same tool, spin on the same parameters, or continue retrying after consecutive failures. Every call consumes context and tokens. Without constraints at the harness layer, this behavior often exhausts budgets before tasks finish, making it difficult to distinguish between a “policy issue” and a “tool-level infinite loop” just by glancing at the logs.
Below is an introduction to the community plugin dsh-tool-governor (maintained by George-Java). It hooks into DSH’s guard and step hooks before and after tool execution, making unified rulings on repeated calls, consecutive failures, and optional per-turn limits. Crucially, it maintains monotonicity after denial to prevent downstream layers from re-approving blocked calls.
What is this¶
dsh-tool-governor is a workflow-category plugin in the DSH ecosystem. In one sentence: it intercepts out-of-control tool calls before tokens are burned.
It addresses three common types of waste:
- Repeated invocation of the same tool name + same argument combination;
- Continued calls to a tool after it has returned structured errors consecutively;
- The need to explicitly set caps on tool calls or model steps per conversation turn (disabled by default to avoid penalizing long tasks).
The plugin hooks into tools/pre-execute, tools/post-execute, ctx.tools.guard, and agent/pre-step at the profile root. It relies only on the global tools service; the agent in the execution context is derived from exec.agent / event.agent.
Core Features¶
The capabilities listed in the documentation are as follows; all thresholds can be adjusted via configuration after installation.
Repeat-call breaker¶
When the same tool name + parameter combination is repeated within a single turn reaching the threshold, the next identical call is denied. The default repeatThreshold is 3, meaning the 4th identical combination will be denied.
Failure-loop cutoff¶
A call is counted as a failure only if the tool returns a structured result satisfying result.isError === true; successful calls that accidentally contain the word “error” in their output text without a structured error flag are not counted as failures. After consecutive failures reach consecutiveFailureThreshold (default 3), the tool is paused.
Optional Per-turn caps¶
maxToolCallsPerTurn: Maximum number of tool calls per turn;maxStepsPerTurn: Maximum number of model steps per turn.
Both default to 0, meaning unlimited. They act as breaker lines only when explicitly set to a positive number, making them suitable for environments requiring hard limits.
Monotonic guard¶
Once a call is denied by this plugin, downstream layers cannot re-approve it (denial is a final state).
Tool blacklist¶
denyTools accepts a list of glob patterns, allowing for the permanent denial of tools such as browser_*.
Turns and Ledger¶
Each new user message resets the corresponding agent’s ledger; repeat counts and failure counts begin accumulating from the new turn.
Installation and Activation¶
The official installation command (using the web profile, consistent with the README):
dsh plugin --profile web add dsh-tool-governor
After installation, restart DSH is required. You can use the following command to confirm the bundle is registered (the README example uses Windows findstr; on Linux/macOS, you can use grep dsh-tool-governor or equivalent filtering):
dsh --profile web --dump-config | findstr dsh-tool-governor
Installing a specific version or from a GitHub source (original text from README):
dsh plugin --profile web add dsh-tool-governor@1.1.0
dsh plugin --profile web add github:George-Java/dsh-tool-governor
Uninstallation:
dsh plugin --profile web remove dsh-tool-governor
Compatibility¶
| Item | Requirement |
|---|---|
| DSH | 0.2.x (README notes testing on 0.2.1-rc.2) |
| Platform | Windows / macOS / Linux |
| Node.js | ^22.19.0 \|\| >=24.0.0 |
License: MIT (current version in package.json is 1.1.0).
Typical Usage: Modifying Configuration in Profiles¶
All configuration items are optional; default values are used if omitted. Simply override the plugin’s config in the profile’s cordis.patch.yml to, for example, increase the repeat threshold or enable per-turn limits as needed:
- id: dsh-tool-governor
name: dsh-tool-governor
config:
repeatThreshold: 5
# Enable only when a hard breaker is needed:
# maxToolCallsPerTurn: 100
# maxStepsPerTurn: 50
Complete configuration fields (excerpted from the README):
| Field | Default | Description |
|---|---|---|
maxToolCallsPerTurn |
0 |
Max tool calls per turn; 0 means disabled |
maxStepsPerTurn |
0 |
Max model steps per turn; 0 means disabled |
repeatThreshold |
3 |
Deny the (N+1)th call with the same tool + args |
consecutiveFailureThreshold |
3 |
Pause the tool after N consecutive structured failures |
denyTools |
[] |
List of tool globs to always deny |
denyMessage |
Built-in | Explanation injected to the model upon denial |
When an interception occurs, you can customize the prompt via denyMessage; if not configured, the plugin’s built-in text is used.
Use Cases and Notes¶
Who is it for
- Running multi-tool agents under the DSH
webprofile, desiring unified governance of call pacing at the harness layer; - Debugging phases requiring quick detection of “repeated identical calls” or “continued retries despite consecutive tool errors”;
- Environments requiring optional per-turn call/step limits instead of default truncation of long tasks.
Please be aware before use
- The plugin runs with the same permissions as the current dsh process; before installing, it is recommended to review the GitHub repository source code and MIT license to ensure the behavior meets your security and compliance requirements.
- The DSH community plugin directory (such as the entry on SkillHub) is maintained by the community and has no official affiliation with DeepSeek / High-Flyer; the installation source depends on the registry or
github:address you actually use. maxToolCallsPerTurn/maxStepsPerTurnare not enabled by default to avoid penalizing normal long-chain tasks; only set them to positive values when a breaker is explicitly needed.
Conclusion¶
dsh-tool-governor consolidates repeated calls, failure loops, and optional per-turn limits into a single set of pre/post guards, maintaining monotonicity after denial to reduce token waste caused by invalid tool round-trips. If you require a lightweight layer of tool governance within your DSH workflow, you can install it using the commands above and adjust the thresholds in cordis.patch.yml according to your scenarios.
- Community Directory: https://www.skillhub.cn/plugins/George-Java/dsh-tool-governor
- Source Code & Documentation: https://github.com/George-Java/dsh-tool-governor