Introduction¶
When running multi-session workflows, background tasks, or sub-agents in DeepSeek Harness (DSH), token usage often gets scattered across different windows and projections. While the built-in interface displays the context consumption for the current task, comparing the “total across all sessions” with the “current main view task”—and further drilling down into per-session and per-turn details—usually requires manually checking logs or calculating costs by hand.
dsh-token-cost is a community plugin that provides a persistent two-line usage and cost estimate footer in the sidebar. Hovering over it expands per-session details, and hovering over a specific row reveals per-turn usage for that session. The data is sourced from existing session projections and Host-side log readings; it adds no new model calls, prompts, or tools. Below is an introduction to its positioning, installation, and typical usage.
What is this¶
- Name:
dsh-token-cost(Repository:wojiao42/dsh-token-cost) - Maintainer: wojiao42
- Version (package.json): 1.7.2, MIT License
- Category: Community catalog entry:
usage(Usage Statistics & Display)
The plugin injects two lines of badges into the DSH sidebar footer: The first line shows the estimated total cost for all sessions (prefixed with a green dot when a task is running); the second line shows the cost and context usage percentage for the current task in the main view. To avoid redundancy, the same total is deliberately not repeated directly below the input box. Costs are estimated using an editable price table, and the metering logic is consistent with the official dsh-token-meter.
Core Features¶
Two-Line Sidebar Badge¶
When the sidebar is expanded, the example format is as follows (amounts are illustrative):
Total ●≈¥0.1240
Current ≈¥0.0330 · 45.4%
- Total: The sum of costs for all sessions with usage data. The timestamp is not shown on the badge but appears in the header of the expanded hover panel.
- Current: The cost of the task in the main view + the usage percentage derived from
contextPressure.projectedTokens / contextWindow. - When the sidebar is collapsed, there isn’t enough width for two lines, so it degrades to displaying only the total amount on a single line.
Hover Detail Panel¶
Hovering the mouse over the badge expands the panel (it collapses after about 0.2 seconds of moving away; clicking pins it, and keyboard focus also expands it). The panel header includes the total amount, as well as meta-information such as session count, running count, cache hit rate, peak usage, timestamp, overall tok/s, and average first token.
Each session in the list occupies two lines:
- Title Row: Status dot, title, tokens, cost, context usage %. The current task is bolded, and running tasks are sorted to the top. Clicking a row switches to that session.
- Time Row: e.g.,
Running 12morLast 3m, Turns/Steps, Avg First Token, Model Duration, Tool Duration, Decodetok/s.
If there are sessions for which projection data has not yet been fetched, a “Load remaining sessions · N” button appears at the bottom of the panel.
Per-Turn Usage Preview¶
Hovering over a specific conversation row triggers a nested layer on the right showing per-turn usage for that session: Each turn is displayed in one line with the turn number and the user prompt that triggered it, followed by a line showing Duration · Timestamp · Steps · Tool Count. Turns with retries are marked “Approximate,” unclosed turns are marked “In Progress,” and usage is shown as — when unprovable. Clicking a turn switches to that session and positions the main view to that specific turn.
Per-turn data is provided by the Host side via GET /token-cost/turns?sessionId=<id>&limit=30[&refresh=1]. It utilizes the official @deepseek-ai/dsh-token-meter’s deriveTurnTokenUsage to fold data, which is the same source as the “Current Turn Usage” in the chat. Both Host and Client cache the data for 15 seconds, and hovering has a 140ms debounce.
Data Caliber (No Extra Model Requests)¶
- Session-level tokens, usage, and model selection come from existing projections (
tokenUsage/contextPressure/modelSelection). - Cold Sessions: The Host baseline only covers the currently active Session. For other windows or background tasks, the plugin calls
ctx.sessions.refreshProjections(id)to collect evidence on demand (it can read all projections without opening the session). The order prioritizes running tasks, followed by most recently updated, fetching a maximum of 48 items per list update without duplicate requests. - Sessions that have been deleted, archived, or are not in the session list have no data and are not included in the total.
- The plugin does not initiate additional model API requests; the client reads projections and logs from the local Host.
Pricing and Cost Estimation¶
Costs are calculated by looking up a table based on the current model: Uncached Input × cacheMiss + (Cache Read + Cache Write) × cacheHit + Output × output. The default table is at the top of client.js (Unit: RMB / Million Tokens):
const PRICES = {
'deepseek-flash': { cacheHit: 0.02, cacheMiss: 0.4, output: 4 },
'deepseek-v4-pro': { cacheHit: 0.02, cacheMiss: 0.4, output: 4 },
};
Models not in the table still display tokens and usage, but the cost column shows —. The README clearly states: This is an estimate, not a bill; dsh-token-meter may underestimate CJK and JSON, and the plugin cannot detect discounts or promotional credits. For billing reconciliation, please refer to the official invoice or modify the table according to actual prices.
Installation and Activation¶
In the DSH ecosystem, plugins are installed via profile combinations. The official command to install from GitHub for the Desktop profile is:
dsh plugin --profile desktop add github:wojiao42/dsh-token-cost
It can also be installed from the plugin market (the community catalog is maintained by awesome-dsh-plugin and has no official affiliation with DeepSeek / QuantFactory). Refresh the page after installation.
Uninstallation:
dsh plugin --profile desktop remove dsh-token-cost
Activation Notes:
- Browser Side (
client.js) only: Toggling thedsh-token-costswitch off and then on in the sidebar “Plugins” page is sufficient; no Harness restart is needed. - Host Side (
index.js) changes (e.g., per-turn routing): A Harness restart is required once. Before restarting, the client may prompt “Per-turn data requires a Harness restart.”
It is recommended to review the repository source code and MIT license before installing. The plugin runs with the permissions of the current DSH process; like any community plugin, the trust boundary depends on the content of the bundle you install.
Typical Usage¶
After following the installation steps above, you can use it in the following order:
- Look at the two lines at the bottom of the sidebar: Total for all sessions and current task cost/usage.
- Hover over the badge to open details, verifying tokens, costs, and time-row metrics for each session.
- Hover over a specific row to view usage for recent turns in that session; if you need to load background sessions, click “Load remaining sessions · N”.
- Click a specific turn in the per-turn preview to jump to the corresponding session and turn for log comparison and troubleshooting.
- If changing models or adjusting prices, edit
PRICESinclient.jsand reload the client bundle by toggling the plugin “Off and On”.
Use Cases and Cautions¶
Who is it for
- Developers running long-term parallel multi-sessions, sub-agents, or background tasks in DSH who need a quick view of “Global Total vs. Current Task.”
- Users who want to perform rough cost calculations using the same
dsh-token-meterrules and drill down to per-turn trigger sentences and step/tool counts.
Things to Note
- Duration (
Running Nm) is an approximate value observed by the client after the page was opened; refreshing the page resets the calculation. Projections do not provide the “absolute start time of this run.” - The README does not provide time-bucketed accounting like “Today’s Spend” or “Spend in last 5 minutes” because existing projections lack corresponding event timestamps.
- The total includes all sessions with usage data; if it differs from the current single session number, it is likely due to cold sessions not yet being fetched. Wait for the panel to load or click “Load remaining sessions.”
- This is a community plugin, not an official app store entry; star counts and popularity are subject to the GitHub page (star count is 0 in the provided clues).
Conclusion¶
dsh-token-cost consolidates token usage and estimated costs (based on editable prices) into a single spot in the sidebar: The two-line badge is for daily glances, the hover panel handles per-session and time dimensions, and hovering a single row drills down to per-turn details with one-click navigation. It does not change model behavior; it only reads existing projections and logs.
- Plugin Directory Page: https://www.skillhub.cn/plugins/wojiao42/dsh-token-cost
- Source Code & Full Documentation: https://github.com/wojiao42/dsh-token-cost