Introduction¶
When using DeepSeek Harness (DSH) locally, it is often necessary to track token consumption and request counts for different models over a period of time. Existing session logs are scattered across various locations, and manual aggregation is both time-consuming and error-prone. The dsh-model-usage plugin introduced in this article adds a “Model Usage” entry to the DSH sidebar, opening a panel that displays per-model token consumption and request statistics.
What Is This¶
dsh-model-usage is a DSH client plugin developed by maintainer HitMargin. It integrates usage-tracking capabilities into the DSH UI, providing a sidebar entry and a central page that display the current model, a per-model usage table (request count, input/output, cache reads, reasoning tokens, totals, last-used timestamp), and the configured provider/model catalog.
Core Features¶
- Sidebar entry: Adds a bar-chart icon to
sidebar.panellist. When collapsed, it shows a tooltip; when expanded, it shows the text label. Button styling, focus, ARIA attributes, and selection state are managed by the shell; the plugin only provides the icon and localized label. - Full-page panel: Registered under the same ID in
main; clicking the sidebar item navigates to this page. - Page content: Current model (provider/model/reasoning intensity), per-model usage table, scan progress (during the initial historical session scan), and the configured provider/model catalog.
- UI copy and metadata are provided in both Chinese and English.
Installation & Enablement¶
This repository is a standard DSH bundle (dsh.bundle.patch + dsh.client). Install this directory as a bundle into the current profile:
plugin_manager action=install_bundle target=<absolute path to this directory>
After installation, refresh the DSH web page to see the sidebar icon. To upgrade or uninstall: disable or remove Model Usage from the plugins page, or run remove_bundle against the same bundle.
Typical Usage¶
The first open requires scanning all historical sessions (on the author’s machine: 435 sessions / ~843 MB of compressed logs, taking approximately 1–2 minutes with a progress bar); subsequent loads use the cache. The statistics scope is limited to local session logs only and does not include sessions from other devices or deleted sessions. Usage data is sourced from the data.usage field in assistant/message events within local session logs, and model identity is taken from data.message.source.{provider,model}. totalTokens is not trusted directly (not all providers populate it); instead, the total is calculated as input + output.
Use Cases & Notes¶
- Suitable for developers who need to monitor per-model token consumption and request counts locally.
- The plugin runs with the permissions of the current
dshprocess. Review the source code and license before installing (this project is open-sourced under the MIT License, Copyright (c) 2026 HitMargin). - Data is stored in
~/.dsh/plugin-data/dsh-model-usage/usage-cache.json. On restart, only modified sessions are re-read; new turns are incrementally accumulated in real time viasession/event. - The host semi-provides a read-only same-origin endpoint
GET /api/model-usage(?action=scantriggers a rescan), with same-origin validation.
In Short¶
dsh-model-usage integrates per-model usage statistics from local session logs into the DSH UI via a sidebar entry and a central page, making it easy for developers to quickly understand token consumption across models. Visit the catalog page and the GitHub repository for more information.