Introduction¶
When developing agents in the DeepSeek Harness (DSH) Web UI, tracking the actual cost of each interaction, subagent, and the entire session tree is essential for cost control. Existing approaches often lack this level of granular transparency. The dsh-chat-cost plugin solves this issue by tracking in real time and providing breakdowns based on a built-in pricing catalog, as well as a local JSONL cost log, giving you a clear view of token usage.
Core Features¶
- Multi-provider pricing: Prices DeepSeek, Moonshot, OpenAI, Anthropic, Google, xAI, and Mistral using a built-in pricing catalog.
- Session-tree cost breakdowns: Displays the cost of individual chats, subagents, and the whole session tree.
- Real-time answer cost: Shows the cost of a specific turn beneath each answer, rather than slicing it from the total session cost.
- Cost log: Creates an append-only JSONL cost log in the project folder (
.dsh-cost/cost.l), recording each session’s location, token buckets, cumulative and incremental costs, and pricing source. - Budget planning tools: Provides a set of commands such as
cost_price,cost_history,cost_estimate,cost_plan,cost_mark, andcost_scenariosfor budget planning. - Multilingual support: Supports English, Chinese, and Russian.
Installation and Enablement¶
Install the plugin using the official command:
dsh plugin --profile web add dsh-chat-cost
After installation, restart the host to activate the plugin.
Typical Usage¶
After installation, configure the plugin settings to enable logging and specify the language.
- id: dsh-chat-cost
name: dsh-chat-cost
config:
writeLog: true # 将 JSONL 成本日志追加写入项目文件夹
logDir: .dsh-cost # 项目文件夹内的目录名
language: zh # 语言选项:en | zh | ru
ledgerTailBytes: 2097152 # 每次摘要读取的成本日志尾部字节数(默认 2 MiB)
The pricing catalog is bundled, but you can refresh it to get the latest prices by running the following command:
npm run prices
Use Cases and Notes¶
- Platform billing differences: Because server-side tool calls (such as search) are billed in addition to session token usage, a platform’s invoice amount may be higher than the session amount tracked by the plugin. The plugin lists these calls but does not include them in internal token pricing.
- Missing sessions: If the host is killed in the middle of a session, the final few minutes of the session may be lost; the plugin will price from the latest checkpoint.
- Checkpoint pricing: Token usage read from a checkpoint is billed at the rate applicable at the time of reading.
- Long-context tier pricing: Long-context tier prices for some Gemini and Grok models have not yet been applied.
- License: The plugin is licensed under the MIT License. Review the source code and license before installation.
Conclusion¶
dsh-chat-cost provides the foundation for cost transparency in agent development. By breaking down costs into session trees and subagents, developers can make better decisions about resource planning. More information and source code are available on GitHub.