Introduction¶
When developing agents using DSH (DeepSeek Harness), it is important to have an intuitive understanding of model invocation costs and efficiency. Existing approaches often rely on manual aggregation or external tools. The dsh-usage-meter plugin adds a “Usage” section to the settings page, aggregates token usage across all sessions by provider and model, and provides time-based trend charts.
What It Is¶
This plugin is maintained by V-dev-388 and is released under the MIT License. It leverages the official Cordis service to passively listen for session events, stores the data locally on disk, and does not depend on any third-party libraries. Its core value is providing zero-external-dependency, local, queryable usage statistics.
Core Features¶
- Aggregated Metrics: Displays request count, total tokens, cache hit rate, input tokens, output tokens, and cached-read tokens.
- Time Ranges: Supports today (24 hourly bars), last 7 days, last 30 days (daily bars), with day boundaries automatically aligned to the local time zone.
- Multi-dimensional Views: Provides provider and model tables, each displaying the respective metrics.
- Refresh Mechanism: Supports automatic polling every 60 seconds and manual refresh.
- Data Coverage: Aggregates all sessions, including sub-agent sessions.
- cc-switch Synchronization: Supports syncing usage data to cc-switch for unified statistics.
Installation and Enablement¶
Use the official CLI to install:
dsh plugin --profile web add dsh-usage-meter
After installation, restart dsh web (or refresh the page to load the client bundle), then open Settings -> Usage.
Typical Usage¶
- View the Dashboard: View the summary cards and trend charts in the “Usage” section of the settings page.
- Query Summary via API:
GET /dsh-usage-meter/summary?range=today\|7d\|30d
- Query Session Details via API:
GET /dsh-usage-meter/sessions
- Disable cc-switch Synchronization:
export DSH_CC_SWITCH_SYNC=0
Use Cases and Notes¶
- Use Cases: Suitable for developers who need to monitor daily token consumption, evaluate cache hit rates, or analyze invocations by model dimension.
- Notes: The plugin only uses the official Cordis service (
sessions/fs/sessionQuery/webServer) and has no external dependencies. The data is fully local, does not access the network, and contains no telemetry. Data is stored in$DSH_HOME/storages/usage-meter.json(using atomic writes).
Conclusion¶
The plugin provides a lightweight local usage statistics solution, suitable for privacy-sensitive users or those who want to integrate usage tracking into existing workflows. The source code and documentation are available on GitHub.