DeepSeek Harness Plugin Hub

Publish and manage complete Harness Profiles. Discover Plugins for your next setup.

Explore

PluginsPresetsDocsNews

Community

Publish a pluginContactReport an issue

Resources

Plugin Hub on GitHubDeepSeek HarnessSystem statusPrivacy notice
© 2026 DeepSeek Harness Plugin HubPowered byPaxTech

Independent and unofficial. Not affiliated with, authorized by, or endorsed by DeepSeek.

Session Budget Guard — DSH Plugin for DeepSeek Harness
DeepSeek Harness Plugin Hub
ProfilesPluginsCategoriesNewsDocsSign inManage Profiles
ProfilesPluginsCategoriesNewsDocsSign in
← Plugins
S

dsh-session-budget-guard

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.

The plugin will be installed here. Keep web if you are unsure.

npx -y @deepseek-ai/dsh plugin --profile web add github:erya2000/dsh-session-budget-guard#4ed01121c139c9a6c981b1cfb4a54d687cb98b49
READMECompatibilityVersions

Compatibility and provenance

Session Budget Guard is published as dsh-session-budget-guard and currently resolves to version 0.1.0. The Hub verifies its manifest and preserves the exact installation source for reproducible installs.

DSH compatibility
*
Runtime surfaces
any
Release source
github
Registry updated
9/16/2026

Versions

0.1.0stable
9/16/2026

Related plugins

Loading related plugins…

Latest
0.1.0
DSH
*
HMR
Process restart
Tree shaking
Safe tree shaking not declared
Unpacked size
Unavailable
Files
Unavailable
Surface
any
License
MIT
Source
github
GitHub
★ 0
Weekly downloads
0
Last push
9/16/2026
View source ↗
README badge

Click the badge to copy Markdown for your README.

Do you maintain this Plugin?Claim benefit · Priority security scan

Verify the GitHub repository declared in package.json to manage this listing. After you claim it, Hub will prioritize a security scan of the current version and publish the result when it passes.

Claim this Plugin →
Report an issue

Related plugins

More verified plugins in models-usage.

Usage@linxin666/dsh-usageUsage statistics plugin for the dsh web GUI: per-provider balance and coding-plan quota detection plus a live token usage ledger, with the current session provider's today usage on the sidebar entryUsage Stats@ychris12138/dsh-usage-statsToken usage heatmap, provider balances, and subscription quotas for the dsh web GUICodex Connectdsh-codex-connectChatGPT OAuth and Codex models for DeepSeek Harness.Ui Usage Billing@kenz1117/dsh-ui-usage-billingUsage billing dashboard for DeepSeek Harness: sidebar cost metrics plus a full dashboard modal, priced from a current multi-provider catalog with real usage aggregated from session logs.

README

dsh-session-budget-guard

English | 中文

A per-session-tree budget and burn-rate circuit breaker for DeepSeek Harness.

One prompt can fan out into a tree of subagents that all spend money at once. This plugin watches each tree — the root session plus every subagent descendant — and refuses the next model request (or the next delegation) when either the tree's total spend or its spend rate crosses a limit you set.

- insert:
    - id: session-budget-guard
      name: dsh-session-budget-guard

Why it exists

On 2026-09-16 a single session ("research a robot dog for the farm") fanned out three levels deep: 3 subagents, then 14, then 28 — 3 494 model calls in 20 minutes, 2 266 of them web searches. It cost ¥82 and drained the API balance; the Harness had no per-session budget, and a cumulative budget alone would have been too slow to matter, because the tree was spending roughly ¥4/minute.

That is why there are two independent gates: cumulative spend and spend rate.

Install

dsh plugin --profile web add dsh-session-budget-guard     # npm (once published)
dsh plugin --profile web add github:erya2000/dsh-session-budget-guard

Or mount it by path from a local checkout (no install step):

# ~/.dsh/cordis.patch.yml
- insert:
    - id: session-budget-guard
      name: /absolute/path/to/dsh-session-budget-guard/lib/index.js

Restart the Harness once after installing (patch layers apply live, but the first mount of a new package needs a boot).

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.
/

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

What it does when a limit is hit

  1. agent/pre-step returns {kind:'reject'} — the next model request never happens, so a stopped tree stops costing money immediately.
  2. tools/pre-execute returns {kind:'deny', reason} for a new subagent / subagent_fork / workflow call past the structure limits, or for a web_search/web_fetch past the quota. The reason is model-visible, so the agent adapts instead of retrying blindly.
  3. Descendants are interrupted deepest-first, then the session turn is cancelled (keepInbox, so queued messages survive).
  4. The event is written to the log, and a notification is sent.

In notify mode only step 4 happens.

Where the numbers come from

  • If the dsh-cost-meter plugin is mounted, the guard reads its ledger through the costMeter service (complete history, user-edited prices; the ledger is USD and is converted with exchangeRate).
  • Otherwise the guard prices calls itself from the llm/stream waterfall using DeepSeek list prices (peak/off-peak, Beijing time) — no dependency, but the totals start when the plugin loads.

Lineage (which session is whose subagent) is read from each session log's first record — id, parentSession, origin, delegationDepth — plus the live session store. Message content is never read.

Limits

  • It is an in-process guard: it stops a tree that is running, it does not resurrect accounting after a Harness restart.
  • notify mode is the default. Turning on enforce means the plugin will cancel a session; tune the thresholds to your own traffic first (run in notify for a day and read the log).
  • Rate limits need at least one sample older than the window, so the first minute of a fresh guard cannot trip on rate — cumulative and structure limits still apply.
  • Plain forks (origin=fork) are deliberately excluded from tree aggregation.

Tests

node --test

18 tests cover the rule engine (lineage, tree aggregation including cycles, sliding-window rate, threshold decisions, waivers, structure gates) and the plugin wiring against a fake host (reject/deny behaviour, search quota, own llm/stream accounting).

License

MIT

statePath
logPath
$DSH_HOME/state/...
Where persistent state and the log live.