dsh-turn-cost: Display Per-Turn Conversation Costs in the DSH Chat Interface

Preface

When using DeepSeek Harness (DSH) for long conversations or multi-tool calls, token consumption is often scattered across multiple rounds of assistant messages. The aggregated numbers in the bill or console are hard to map one-to-one with the “round” on the interface. If you want to see how much each round cost directly in the local chat window, you need to parse the session and stitch together the usage yourself, then mount a component on the UI.

Below, I introduce the community plugin dsh-turn-cost (maintainer OCAN107, category: client). It displays the estimated cost of each round next to the timestamp of that round, making it easy to troubleshoot expenses by comparing with historical sessions.

What is this

dsh-turn-cost is a standard DSH plugin, current version 0.1.0, license MIT, source code at GitHub: OCAN107/dsh-turn-cost.

One-sentence positioning: In the DeepSeek Harness chat interface, render the total token cost of a single turn as “number + fish emoji” next to the timestamp; hover to see the precise RMB amount down to 0.0001 yuan.

Costs are accumulated by (sessionId, turn), including all tool calls and multiple model requests in that round, not the total price of the entire session.

UI Representation

The row after a round ends looks roughly like this (the fish emoji is the display character agreed upon by the plugin, see README examples):

Completed a round of response           0.13🐟   Nov 14 22:08

Several empty data or error states are distinguished by fixed characters: … loading, ·· turn not found, !! request failed, ? session unavailable.

Existing usage for historical sessions is backfilled from ~/.dsh/sessions under existing session.v4.jsonl.zstd when the plugin starts; badges are visible in old conversations as well.

Core Capabilities (Verified)

  1. Pricing by Turn: Host subscribes to session/event, only processes type === 'assistant/message', reads four token buckets from event.data.usage and accumulates.
  2. Historical Backfill: Scans the session directory at startup, cuts frames and decompresses jsonl using zstd magic numbers, and writes historical usage into an in-memory table.
  3. Client Display: Browser module mounted to conversation.chat.turnTail slot; turns with an assistant-actions icon row are moved to the action area for display, avoiding two numbers in the same turn.
  4. HTTP Query: Registers POST /api/dsh-turn-cost (query price by messageIds or sessionId) and POST /api/dsh-turn-cost/report (client self-inspection reporting).
  5. Configurable Unit Price: Modify PRICES (yuan / million tokens) at the top of lib/index.js; restart DSH after changes.

Installation and Enablement

The README for this plugin provides link dependency + bundles, not a command like dsh plugin add. Read the repository source code and confirm the MIT license before installing; the plugin runs with the current DSH process permissions and has no bundled relationship with official DeepSeek or Hypersphere.

1. Place Plugin Directory

Place the entire repository in ~/.dsh/plugins/dsh-turn-cost (or your custom path).

2. Modify profile’s package.json

In the package.json of the profile you use (e.g., desktop), add the dependency and list the plugin in bundles:

{
  "dependencies": {
    "dsh-turn-cost": "link:C:/Users/you/.dsh/plugins/dsh-turn-cost"
  },
  "dsh": {
    "bundles": [
      "@deepseek-ai/dsh-base",
      "@deepseek-ai/dsh-web-app",
      "dsh-turn-cost"
    ]
  }
}

Change the link: path to the absolute path of your local plugin directory (same logic applies on Linux using local paths, no need to stick to C:/ in the example).

3. Windows: Create Junction

Point to the plugin directory under the profile’s node_modules:

New-Item -ItemType Junction -Path "$env:USERPROFILE\.dsh\profiles\desktop\node_modules\dsh-turn-cost" -Target "$env:USERPROFILE\.dsh\plugins\dsh-turn-cost"

4. Completely Restart DeepSeek Harness

Need to end all DeepSeek Harness processes in Task Manager and restart; simply closing the window doesn’t count as effective.

Configure Unit Price

The default price table is at the top of lib/index.js, unit yuan / million tokens:

const PRICES = {
  uncachedInput: 2.0, // Input not hitting cache
  cacheRead: 0.2,     // Input hitting cache
  cacheWrite: 2.0,    // Writing to cache
  output: 3.0,        // Output
};

Modify these four numbers according to your actual billing rules, save, and restart DSH.

Typical Usage

After installation and restart, the round-cost badge will automatically appear for new or existing sessions in the chat list, generally requiring no extra commands.

If you want to perform client self-inspection, you can report to the Host (routes see above); for daily development, rely on the numbers next to the interface timestamp. The price query API accepts { messageIds } or { sessionId }, making it easy to interface with self-built panels or scripts — refer to the current implementation in the repository for the specific request body.

Applicable Scenarios and Notes

Suitable for: Doing agent debugging, comparing single-round costs of different prompts or tool chains in the DSH Web client; when you need to align costs with timestamps instead of just looking at the session total.

Limitations (as stated in README):

  • If there are multiple assistant messages within the same turn (e.g., intermediate messages during tools), the same number may appear after each, because the statistical dimension is the turn, not a single message.
  • The amount is an estimate of token count × fixed unit price, excluding discounts, bonus quotas, or actual price differences between different models.
  • Only counts usage for assistant/message; if a sub-agent uses an independent session, it will not be included in the parent turn.

The DSH ecosystem emphasizes “everything is a plugin”; the plugin directory page for dsh-turn-cost on SkillHub is a community index, not part of the same system as the official DeepSeek app store. It is recommended to review lib/index.js and lib/client.js yourself before enabling.

Conclusion

dsh-turn-cost aggregates session usage into a cost tip of “one small grid per round,” reducing the cost of switching back and forth between comparing jsonl and the bill. If you want to install or change prices, refer to the repository README and version 0.1.0.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye