Preface¶
When running agents in DeepSeek Harness (DSH), the interface typically shows “cost,” “latency,” and session-level token statistics. These numbers tell you how much was consumed, but they rarely answer two questions directly: exactly where your RMB went across token categories, and whether the metrics actually improved after you adopted the recommended changes to your usage.
DSH Cost Audit is a Web-side plugin maintained by community member Pingze-github. It hooks cost and its breakdown into the harness’s existing statistical display, then re-measures relevant metrics after suggestions are adopted—so that “I did what it said” corresponds to a set of readings, not a subjective impression.
What Is This¶
DSH Cost Audit (dsh-cost-audit, current package version 0.1.0, MIT license) targets the DeepSeek Harness Web GUI. It focuses on a single question: where did the money go, and did doing what it says actually work?
The plugin does not modify the geometry or styling of the official “cost” and “latency” capsules; it appends its own capsules alongside them, reusing the same icon-capsule, dt/dd panel, and design tokens. Amounts are estimated from DeepSeek’s official RMB list prices; account balance is read live from the billing API and can be used to calibrate the estimate.
Core Features¶
Per-Turn and Per-Session Cost Capsules¶
Per-turn: On each assistant action row, between the copy button and the branch button—immediately next to the official “cost” and “latency” capsules—a new capsule shows the RMB for that turn (e.g., ¥0.01). Clicking it reveals model routing, cache hit ratio (not rounded into a fake 100%), cache-read / cache-miss-input / cache-write / total-input / output tokens, and the turn’s cost along with a timing breakdown.
Per-session: On the same row as the session statistics, a summary such as ¥2.72 · today ¥0.41 · Account balance ¥113.45 is appended—session total, today’s spend within this session (when reopening a session the next day, “today” starts from zero rather than reusing lifetime numbers), and a live account balance. The panel also includes a token-bucket breakdown of the entire persistent log, a timing distribution, and the balance with gift / top-up composition read from DeepSeek’s billing API.
Among items often unaccounted for elsewhere, the plugin separately lists the summary call during context compaction as its own bill line, and distinguishes manual compaction from harness-system automatic compaction.
Timing Distribution¶
Every per-turn and per-session panel’s usage section ends with “where did the time go.” Tool rows are sorted by name and include total elapsed time, model time, average time to first token (TTFT), generation phase (including tok/s), tool time, other overhead, and a breakdown of the six most active tools (the rest are merged into one row). Event anchors come from harness log entries such as turn/start, step/start, tool/call, etc.
Token-Saving Suggestion Engine¶
A fourth “Suggestion” capsule appears only when data actually supports it; healthy sessions don’t waste space on it. Suggestions are derived by collapsing the persistent log—no model calls are made. Each item carries a severity, a one-line fix, and a session-stored “ignore” flag saved in the browser.
| Code | Trigger Condition (Summary) | One-Click Action |
|---|---|---|
context-reread |
Cache re-read ≥ 35% of session spend, and model calls ≥ 30 | Submit /compact to compact this session immediately |
fragmented-tools |
A tool called ≥ 30 times, with ≥ 60% taking under 2 seconds | Have the agent batch them into a script |
repeated-target |
The same tool targeting the same object ≥ 4 times | Read once, record conclusions, then use grep |
idle-grinding |
≥ 30 consecutive steps with no write / edit / deliverable | Ask for a progress report |
tool-failures |
The same tool failing 3 times consecutively | Stop and read the error |
cache-hit-drop |
Hit rate < 85% across 50+ calls | Investigate why request headers change each turn |
compaction-churn |
System auto-compaction ≥ 3 times or summaries ≥ 10% of session | Needs host config changes (explained in panel) |
model-retries |
Model retries ≥ 5 times | Manual handling instructions |
balance-low |
At current pace, balance won’t last ~5 more sessions | Top up, etc. |
Manual /compact does not count toward the “frequent compaction” system-automatic count; compaction-churn only looks at compactions the harness itself decides. Amounts are displayed to two decimal places; real spend that is positive but below display granularity shows <¥0.01.
Adopting Suggestions and Re-measuring¶
Executable suggestions are submitted into this session via the input box’s setDraft + submit, using the same path as the send button, so the agent reads them on its next step. When the input box is non-empty the execute button is disabled; each suggestion disables itself after being sent to prevent duplicate clicks.
After adoption, suggestions remain in the list and their verdict is updated per session: Adopted · Improved / Essentially unchanged / Actually worse / Still observing. The verdict block states exactly what was executed (e.g., Executed /compact); when the sample is insufficient it provides the baseline and how much more evidence is needed; for compaction it also appends that command’s cost after the summary lands. Readings start from the snapshot at adoption time, and suggestion-related metrics (context tokens, short-call ratio, repeated calls, failure ratio, cache hit rate, etc.) are compared against baseline ratio thresholds. Interface language follows the harness: zh for Simplified Chinese, en for English.
Account-Wide and Granular Views¶
Account-wide · Last 7 days: Daily buckets merged across all sessions, answering cross-session questions like “did I spend less than before?” Two denominators are kept on the output side: per delivered edit (cost of each write / edit / present) and per 1K answer tokens; curves plot re-read / cold-input / output, with compaction summaries as a subset (not a fourth category), peak share, etc. Data comes from collapsing the persistent log; history can be backfilled (up to ~90 days). The panel notes: amounts are list-price estimates; some call logs have no usage, so the report is a lower bound; trends cannot be automatically attributed to suggestions you adopted.
Granular: The same event batch split by minute / hour, one row per metric (each divided by call count). The window determines bucket width: 2 hours→1 minute, 24 hours→5 minutes, 7 days→1 hour. Changes in thinking tier, model switches, sub-agents, /compact, compaction summaries, preset switches, etc. are marked as vertical dashed lines. Context tier and concurrency toggles are provided for comparing strategies within the same tier.
Pricing Rules (Summary)¶
Pricing references the yuan per 1M tokens from DeepSeek’s official documentation; peak hours are Monday–Friday 09:00–12:00 and 14:00–18:00 Beijing Time, with all other times and weekends at half price. The deepseek-flash family and the deepseek-pro / deepseek-v4-pro family each have their own peak / off-peak unit prices for cacheHit, cacheMiss, and output; model names without the v4 or deepseek marker count tokens but are not priced, and cost displays —.
Installation and Activation¶
The plugin runs with DSH process permissions. Before installing, review the GitHub repository source and MIT license yourself.
Web profile installation:
dsh plugin --profile web add github:Pingze-github/dsh-cost-audit
After installation, refresh your browser to load the client bundle. For local-checkout development, use a live link:
dsh plugin --profile web add link:/path/to/dsh-cost-audit
If dsh-hotswap is already installed, the new bundle can be hot-mounted; restarting dsh web is generally unnecessary (a restart would terminate the currently hosted session). Renaming a link:-installed plugin may leave an unremovable startup entry in the profile and duplicate bundle registrations; the fix is to remove the entry from the profile manifest and re-add it, not merely restart.
Optional configuration is written into the profile patch layer under the same id, e.g. billing baseUrl, credentialRef (default DEEPSEEK_API_KEY), balanceCacheMs, requestTimeoutMs, and pricing overrides for flash / pro peak / off-peak unit prices.
Typical Usage¶
-
Install the plugin for the
webprofile using the command above, then refresh the page. -
Open any session and check the new RMB capsule on each assistant turn’s action row; click it to verify model, cache buckets, and the timing breakdown.
-
Check the session total, today’s spend, and account balance on the session header statistics row; for cross-session trends, open “Account-wide · Last 7 days” at the bottom of the cost panel.
-
When the “Suggestion” capsule appears, read the trigger reason; if the input box is empty, click one-click adopt on executable items, then check the “Adopted” verdict and baseline comparison in the list.
-
To calibrate the balance or change the API endpoint, set
credentialRefand optionalbaseUrl,pricingfordsh-cost-auditin your profile.
Use Cases and Caveats¶
Suitable for: Front-end / full-stack / agent developers who run agents in DSH Web long-term, need RMB-dimension token breakdowns, care whether compaction summaries silently burn money, and want reproducible metrics to verify whether usage changes actually work.
Caveats:
- Costs are estimates based on vendor-reported usage; balance is read live and can be used for cross-checking.
- The suggestion engine triggers conservatively and does not call any model; “Essentially unchanged” should be treated as a common honest outcome.
- Reports cannot prove that a spending change was caused by a specific suggestion; you need to align adoption time with trends yourself.
- The community plugin directory SkillHub entry is not officially affiliated with DeepSeek or 幻方; the DSH ecosystem philosophy is “everything is a plugin,” and the repository README and source code are authoritative.
Closing¶
DSH Cost Audit extends the harness’s existing statistical positions into an actionable cost audit: from per-turn and per-session to account-wide and granular curves, and turns “adopt suggestion → re-measure” into numbers on the panel. For more information and issues, see GitHub: Pingze-github/dsh-cost-audit; directory page: SkillHub — dsh-cost-audit.