AI Agent Hub
Back to plugins
🧩

dsh-turn-budget

admin-security Updated 2026.08.17

Run the following command in DeepSeek Harness:

dsh plugin install Nunchakus888/dsh-turn-budget

Paste the following prompt into your AI chat to install this plugin:

Install in DeepSeek Harness by running dsh plugin install Nunchakus888/dsh-turn-budget; the full source is available at https://github.com/Nunchakus888/dsh-turn-budget

About this plugin

When an Agent chain-reactors through model calls, nested tools, and token spend in a single turn with no hard ceiling, one runaway loop can burn through a provider quota or starve downstream services in minutes. dsh-turn-budget is a fail-closed, per-turn resource governor for DeepSeek Harness: it does not estimate currency, rewrite tool arguments, or replace sandboxing; it simply locks each turn to a hard ceiling and rejects anything that exceeds it.

Enforcement works through public Harness extension points at three independent layers. Before the next model request, the plugin checks step count and provider-reported token usage (including cache read/write buckets) and closes the turn as blocked if either ceiling is hit. Before each tool body is dispatched, it tallies root calls and Code Mode nested dispatches; excess calls receive a policy error naming the exceeded budget while the model retains one opportunity to finish without another tool. Token accounting trusts only explicit provider usage reports and never estimates; the tool ledger is process-local, keyed by live Agent identity, and discarded on restart so no stale in-flight state can survive.

Teams running multi-tool orchestrations, heavy Code Mode nesting, or deployments where provider quotas are scarce will benefit most. It slots in front of existing sandboxing and approval layers without replacing them, adding one precise circuit-breaker gate that keeps a single turn from consuming an entire budget.

Use Cases

  • Multi-tool orchestration agents spiraling into uncontrolled tool-call loops within one turn
  • Code Mode nested dispatches consuming more provider tokens than the budget allows
  • Production deployments needing a hard ceiling so a single runaway turn cannot exhaust provider quota

Best For

  • Teams building multi-tool Agent orchestration platforms that need per-turn hard resource guards
  • Deployments with provider quota sensitivity where a single runaway turn must not consume the entire budget
  • Engineering teams with existing sandboxing and approval flows who want an additional circuit-breaker gate