DeepSeek Harness 的失败关闭型资源治理器:限制模型步数、根/嵌套工具执行数与供应商上报的精确 token 用量
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…
安装
dsh plugin --profile web add github:nunchakus888/dsh-turn-budgetGitHub 源码安装:首次需按提示配置 allowBuilds 构建授权后重试
安装与环境配置指引、插件开发教程见 DSH 中文社区文档 ↗
安装即在你的机器上以你的权限运行第三方代码——它可读写文件、使用凭据、访问网络,DSH 的工具审批不会为插件代码加沙箱。「检测到 manifest」仅代表发现 dsh.bundle / dsh.plugin 清单,不构成兼容性或安全审查;安装前请审阅源码,不熟悉的插件先在不含密钥的环境试用。
README
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-steprejects a model request that would exceed the step or provider-token ceiling.tools/pre-executedenies a tool body before dispatch when the turn has consumed its tool-call allowance.- Existing
tool/resultandturn/endrecords 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
| Limit | Enforcement point | Counted work | Outcome |
|---|---|---|---|
maxStepsPerTurn |
Before the next model request | Entered requests in the current turn | The proposed step is rejected; the turn closes as blocked. |
maxToolCallsPerTurn |
Before each tool body | Root calls plus Code Mode/nested dispatches carrying the Agent | Excess calls return a policy error naming the exceeded budget; the model retains one opportunity to finish without another tool. |
maxProviderTokensPerTurn |
Before the next model request | Latest provider usage per step, including cache read/write buckets | The 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
原始 README: https://github.com/Nunchakus888/dsh-turn-budget/blob/main/README.md ↗
同类插件
查看全部 →
k8e
k8e.sh — 开源 Agentic AI 沙箱矩阵

hol-guard
开源AI代理防病毒:运行时拦截风险工具、秘密访问、提示注入、恶意软件包、MCP服务器、插件和技能。

anolisa
ANOLISA(Agentic Nexus Operating Layer & Interface System Architecture):具备运行时、安全性、可观测性和 Tokenless 响应压缩能力的 Agentic OS,可降低 Token 使用量与成本。

mobius
首个自我演进的开源 Agent OS:连接你的团队、AI agent、设备与算力

deepseek-harness-desktop
DeepSeek Harness Tauri 桌面版 | Only 5mb installer, zero environment setup. Windows / macOS / Linux.

open-managed-agents
开源Claude管理代理API实现和自托管Claude标签式代理运行时。即插即用;在Cloudflare Workers/Durable Objects或Node.js上运行。Apache 2.0。