Nunchakus888 / dsh-turn-budget

목록에 있음

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

main모델도구 소스 보기

설치

npx -y @deepseek-ai/dsh plugin --profile web add github:Nunchakus888/dsh-turn-budget

이 설치 명령은 GitHub 저장소 주소에서 생성된 확인되지 않은 시작점입니다.

README

유지 관리자가 작성한 문서 스냅샷입니다.

GitHub에서 보기 ↗
커밋 9583ad3동기화 2026. 8. 18.

dsh-turn-budget

CI

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

프로젝트 파일 및 신호

표시된 항목은 디렉터리 스냅샷에서 감지된 공개 저장소 신호입니다.

테스트감지됨
문서감지됨

저장소 정보

언어
TypeScript
라이선스
MIT
최신 릴리스
v0.1.0
마지막 업데이트
2026. 8. 14. 오전 3:53

신중하게 설치하기

소스 코드, 권한, 수명 주기 스크립트, 의존성 및 네트워크 접근을 검토하고 신뢰하지 않는 플러그인은 격리 환경에서 테스트하세요.