- Home
- Plugin
- Utilizzo e fatturazione
- dsh-task-budget
dsh-task-budget
andromder/dsh-task-budget
Per-task cost dashboard and budget guard that prices each model call at peak or off-peak rates, turns the remaining budget into a per-turn work envelope in the system prompt, and stops the task at its cap until the user replies. The default cap is ¥0.5 per task.
Installazione
dsh plugin --profile web add github:andromder/dsh-task-budgetREADME
Task budget (dsh-task-budget)
A DeepSeek Harness plugin with a left-sidebar panel for per-task spend, a per-task cost cap, and a live budget brief that is generated for the model on every turn.
What it does
- Left sidebar → 任务预算 / Task budget. Lists every task (session) with its
token totals, actual CNY cost, a budget bar, and status. Click a row to see:
- every model call: time, peak/off-peak tier, model, input / cache / output tokens, that call's cost, and the running total;
- the exact budget brief the model sees for that task (collapsible).
- Per-task cap. One number (default ¥0.5) applies to each new task or conversation. It is never shared across tasks.
- Hard stop at the cap. The next step is forced to ask you with
ask_user_question, and every tool exceptask_user_questionis denied until a human answers. One reply of yours buys a full continuation allowance: the cap becomes at leastspent + continuationStepCny. - Approvals survive reloads. Grants are persisted in
$DSH_HOME/budget-guard/grants.json, so a plugin/Host restart does not ask again for a task you already approved.
How the budget reaches the model
The prompt has two sections:
-
Rules (
budget-guard:rules, static): real rates, the money scale (¥0.05 ≈ 1 short answer,¥0.15 ≈ 2-3 calls,¥0.30 ≈ 5 calls,¥0.50 ≈ 8-10 calls,¥1 ≈ 15 calls), and the shortest-path discipline. -
Task brief (
budget-guard:brief, dynamic, per answering agent): rebuilt for every step with live numbers:【本任务预算简报 · 自动生成,优先级高于其他计划】 上限 ¥2.306|已花 ¥1.306|剩余 ¥1.000|谷时|平均每次调用 ¥0.050(约可再调用 20 次) 本轮请求:把左侧栏入口的价格显示改成“元/百万 token”… 判定:小改动(精简执行)|本轮上限:4 次调用 / 1 个文件 策略:精简执行。直接改完并做 1 次最小验证;最多 4 次调用、1 个文件。 硬约束:以上次数/文件数是硬上限…;不扫描全仓库…
The budget → prompt algorithm
All local and free (no extra model call):
- Classify the request from the latest substantive user message:
length, keywords (
重构/迁移/全量weigh 2;新增/实现/修复/测试/文档weigh 1), multi-file phrases, and whether it is a pure question. Result:answer | small | feature | large. - Measure the real burn rate: average CNY per model call from this task's own committed usage (default ¥0.06 before the first call).
- Convert money into a work envelope:
affordable = floor(remaining / avg)and pick a strategy —full,lean,minimal,diagnose(diagnose only, no edits),answer(no tools), orstop(not enough for one call). - Emit hard limits into the prompt: maximum model calls, maximum files, search/read limits, the required one-line budget estimate, and the stop rule when less than one call's money remains.
The model therefore sees not just "the cap is ¥0.5", but "you have ¥1.00 left, about 20 calls, this request is a small change, use at most 4 calls and 1 file".
Settings
The panel writes $DSH_HOME/budget-guard/settings.json:
{
"enabled": true,
"capCny": 0.5,
"continuationStepCny": 0.5,
"warnRatio": 0.8,
"inputIncludesCache": true,
"peakWindows": [{ "start": 1, "end": 4 }, { "start": 6, "end": 10 }],
"holidays": [],
"models": {}
}
peakWindowsuses UTC hours (1–4 and 6–10 are 09:00–12:00 and 14:00–18:00 Beijing).modelsoverrides rates, e.g.{"deepseek-flash": {"offPeak": {"cacheHit": 0.02, "cacheMiss": 1, "output": 4}, "peak": {"cacheHit": 0.04, "cacheMiss": 2, "output": 8}}}. A model entry with onlycacheHit/cacheMiss/outputis priced flat.inputIncludesCachefollows DeepSeek accounting:inputTokensalready contains cache-hit tokens, so the miss count isinput - cacheRead - cacheWrite.
Notes
- Cost is folded from committed
assistant/messageusage events, priced at each call's own timestamp (peak/off-peak), so it is reconstructable from the log. Historical sessions are read on demand (the newest 12 are queued when the panel opens; older rows compute when opened) and cached in memory. - Real prices: off-peak CNY 0.02 / 1 / 4 per 1M tokens (cache hit / miss / output); peak is double. Peak = Beijing Mon–Fri 09:00–12:00 and 14:00–18:00; weekends and holidays are off-peak all day.
- Subagent sessions are separate tasks and are listed with a
子任务badge.
Plugin correlati
DeepSeek-Balance-Whale-Widget
meteornox/deepseek-balance-whale-widget
dsh-context
bowenliang123/dsh-context
dsh-cost-meter
han-1413141/dsh-cost-meter
dsh-damage-pulse
wssfk12138/dsh-damage-pulse