Introduction¶
The core idea of DeepSeek Harness (DSH) is that “everything is a plugin.” When developing agents or engaging in long conversations, accurately understanding the cost of the current session is a common need. Session logs usually contain detailed token usage, but it is scattered throughout the logs and hard to view at a glance. The dsh-conversation-cost plugin directly reads the authoritative usage data from session logs, converts token consumption into monetary cost, and applies billing based on time periods and caching strategies.
What is dsh-conversation-cost¶
This is a DSH plugin maintained by Uersx, categorized under model inference. Its main purpose is to calculate in real time how much the current conversation (current session) has cost. It is based on the real usage carried by each assistant/message in the session logs (the token counts returned by the provider), estimates cost according to the official DeepSeek V4 pricing, and distinguishes between peak and off-peak periods.
Core Features¶
- Real-time cost display: Persistent display of
¥X.XX · N 次at the bottom of the sidebar, auto-refreshed every 5 seconds. This display completely replaces the badge slot of the out-of-the-box Cordis panel. - Real data reading: It does not estimate token counts; instead, it directly reads authoritative usage from the session logs, including
inputTokens,outputTokens,cacheReadTokens,cacheWriteTokens, andreasoningTokens. - Segmented billing: Based on the actual time each call occurred, it distinguishes peak hours (daily 9:00–14:00) from off-peak hours, accumulates costs separately, and does not apply a single uniform price to the entire period.
- Cache-hit pricing: Input billing includes cache-miss input, cache writes (billed at the cache-miss price), and cache hits (billed at 1/30 of the cache-miss price). Output billing is calculated at the output price.
- Model tool: Provides the
conversation_costtool, which the model can actively call to obtain per-call details and a summary. - Skill: Provides the
conversation-costskill, guiding the model on when to call the tool and how to report costs.
Installation and Enablement¶
Before installing, make sure DeepSeek Harness is installed and the profile is configured. Local directory installation and GitHub remote installation are supported.
# 从本地目录安装
dsh plugin --profile demo add /path/to/dsh-conversation-cost
# 从 GitHub 安装(自动拉取源码并构建)
dsh plugin --profile demo add github:Uersx/dsh-conversation-cost
After installation is complete, verify whether the configuration layer is loaded successfully:
dsh --profile demo --dump-config
The output should include the # == dsh-conversation-cost layer.
Typical Usage¶
When the user asks “how much does the current conversation cost” or “what is the cost,” the model automatically triggers the conversation_cost tool.
Tool call parameters:
{
"timeBucket": "auto"
}
The timeBucket parameter is optional:
* auto: default; billing is applied separately based on the actual time of each call.
* peak: all calls are billed at peak pricing.
* off-peak: all calls are billed at off-peak pricing.
Tool return example:
当前对话(会话 session-xxx)模型费用估算(按每次调用实际时段)
- 模型调用:171 次,其中可计价 171 次
- 总费用:¥3.8600
· 空闲时段:¥3.8600(171 次调用)
· 高峰时段:¥0.0000(0 次调用)
- 输入 tokens:759975(缓存命中 20600448,缓存写入 0)
- 输出 tokens:140346
Use Cases and Notes¶
- Sidebar display limitation: The sidebar cost reading is loaded only when the plugin is installed by package name into a profile with the full UI (for example,
dsh plugin --profile web add ...). When mounting with a--patchsource path, only the host side is loaded (core logic and tools are available, but the sidebar reading will not appear). - Billing accuracy: The cost shown by the plugin is an estimate based on official pricing; the actual cost depends on the platform bill. For unknown models, token statistics are listed separately but are not included in the cost.
- pnpm dependency limitation: If your pnpm version is ≥ 10 or ≥ 11 and you install this plugin directly from Git, the first installation may report the
ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWEDerror. You need to add anallowBuildsconfiguration whitelist in the profile’spnpm-workspace.yaml.
Conclusion¶
dsh-conversation-cost provides DSH users with a complete loop from log data to cost estimation. It enables real-time monitoring through the sidebar and also allows the model to actively report costs via the tool. It is suitable for long conversations or agent development scenarios where cost sensitivity is important.