DeepSeek Harness plugin

dsh-turn-budget-nunchaku

Fail-closed per-turn step, tool-call, and provider-token budgets for DeepSeek Harness

Jump to install

Source facts

Repository
Nunchakus888/dsh-turn-budget
Latest update
Aug 14, 2026
Category
Models & Providers
GitHub stars
1
Format
plugin
Catalog evidence
Upstream dsh.bundle evidence
Evidence path
package.json#dsh.bundle
Checked against
0.1.0-rc.8
Upstream check date
2026-08-20

This evidence comes from the upstream catalog. This site has not installed, run, or security-reviewed the plugin.

Install

Start with a prompt that asks an agent to review the GitHub repository and source. Switch to the command if you want to install it yourself.

Copy this prompt into DSH, Codex, or another agent and ask it to review the GitHub repository and source first.

Do not install or run any commands yet. Read this plugin's GitHub repository, README, and relevant source code. Then answer the questions below clearly and directly so I can decide whether it fits my needs:

1. What is this plugin, and what problem does it solve?
2. Who is it for, and what are its typical use cases?
3. How is it used after installation? Include one minimal example.
4. What known limitations or privacy, security, compatibility, or maintenance risks does it have?
5. Give a clear recommendation: recommend, conditionally recommend, or do not recommend, with reasons.

Distinguish statements documented by the repository, inferences from source code, and unknowns. If evidence is insufficient, say so explicitly. Do not guess or simply repeat the README.

GitHub: https://github.com/Nunchakus888/dsh-turn-budget
Plugin: dsh-turn-budget-nunchaku
Author: Nunchakus888

Check the source files

Read the README and other files from this plugin directory before installing.

File explorer3 files
README.mdSource · read only

dsh-turn-budget

![CI](https://github.com/Nunchakus888/dsh-turn-budget/actions/workflows/ci.yml)

dsh-turn-budget is a fail-closed resource governor for DeepSeek Harness. It limits model steps, root and nested tool executions, and exact provider-reported token usage independently for every Agent turn.

The plugin uses public Harness extension points only:

  • agent/pre-step rejects a model request that would exceed the step or provider-token ceiling.
  • tools/pre-execute denies a tool body before dispatch when the turn has consumed its tool-call allowance.
  • Existing tool/result and turn/end records preserve the resulting policy outcome in the canonical Session log.

This is a circuit breaker, not a billing system. It does not estimate currency, rewrite tool arguments, replace sandboxing or approvals, or terminate an uncooperative model/tool operation in the middle of a step.

Install from a checkout

git clone https://github.com/Nunchakus888/dsh-turn-budget.git
dsh plugin --profile web add ./dsh-turn-budget
dsh --profile web --dump-config
dsh --profile web

The bundled profile layer enables a conservative baseline of 24 model steps and 40 tool executions per turn. Override the complete row in the profile's cordis.patch.yml when a deployment needs different ceilings:

- update:
    id: turn-budget
    config:
      maxStepsPerTurn: 16
      maxToolCallsPerTurn: 32
      maxProviderTokensPerTurn: 250000

Every configured limit must be a positive safe integer. At least one limit is required.

Enforcement semantics

LimitEnforcement pointCounted workOutcome
maxStepsPerTurnBefore the next model requestEntered requests in the current turnThe proposed step is rejected; the turn closes as blocked.
maxToolCallsPerTurnBefore each tool bodyRoot calls plus Code Mode/nested dispatches carrying the AgentExcess calls return a policy error naming the exceeded budget; the model retains one opportunity to finish without another tool.
maxProviderTokensPerTurnBefore the next model requestLatest provider usage per step, including cache read/write bucketsThe proposed step is rejected after the reported total reaches the ceiling.

Token enforcement is exact only when the provider reports usage. Missing provider usage is not estimated. A provider can exceed the configured ceiling inside its current response; the plugin prevents the following request because the public lifecycle exposes no preemptive token stream budget.

The tool ledger is process-local and keyed by live Agent identity. Cold recovery closes interrupted turns before they can continue, so a process restart cannot resume an old in-flight ledger.

Development

pnpm install
pnpm run check

The integration tests boot the real Agent Loop with the published Harness testkit. They cover step rejection, pre-dispatch tool denial, per-turn reset, final-response allowance, provider-token accounting, and duplicate usage replacement.

License

MIT