erya2000/dsh-session-budget-guard ↗★ 0

dsh-session-budget-guard

Per-session-tree budget and burn-rate circuit breaker for DeepSeek Harness: refuses the next model request or delegation when a tree's spend or spend rate crosses a limit. 适合需要严格限制单个会话或代理调用预算、防止模型无限循环跑飞扣费的用户。

패키지
dsh-session-budget-guard
호환성
미검증
버전
0.1.0
라이선스
MIT
최근 업데이트
2026. 9. 16.

설치

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:erya2000/dsh-session-budget-guard

Configuration

Every key is optional; the defaults live in lib/rules.js. Unknown keys are logged and ignored rather than silently dropped.

KeyDefaultMeaning
modenotifynotify = log + notify only. enforce = also refuse the next step, deny over-quota delegations/searches and stop the tree.
enabledtrueMaster switch.
treeWarnCny20Warn once per tree at this cumulative spend.
treeStopCny50Stop the tree at this cumulative spend.
rateWarnPerMin4Warn when the tree grows faster than ¥4/min.
rateStopPerMin8Stop the tree when it grows faster than ¥8/min.
windowsSeconds[60, 180]Sliding windows used for the rate, in seconds.
maxDelegationDepthnull (off)Deepest allowed subagent depth. 1 means subagents may not spawn subagents.
maxTreeNodesnull (off)Most subagents allowed in one tree.
maxSearchesPerSessionnull (off)Most web_search/web_fetch calls allowed per session.
dailyWarnCny / dailyStopCny100 / 300Reported in warnings for the whole day across trees.
stopStreak2Consecutive over-limit checks before acting.
notifyCooldownSeconds300Minimum gap between notifications for the same tree.
notifyautoauto (macOS: osascript), none, or a shell command template containing {text}.
exchangeRate7.2Used to convert the cost-meter ledger (USD) into CNY.
statePath / logPath$DSH_HOME/state/...Where persistent state and the log live.

A configuration tuned for enforcement (this is what the incident above led to):

config:
  mode: enforce
  treeWarnCny: 5
  treeStopCny: 10
  rateWarnPerMin: 1.5
  rateStopPerMin: 3
  maxDelegationDepth: 1
  maxTreeNodes: 6
  maxSearchesPerSession: 40