Introduction

When running agents in DSH (DeepSeek Harness), costs are typically distributed across multiple sessions, model invocations, tool invocations, and cached results. Looking only at the total tokens makes it difficult to determine which session, model, or tool is most expensive, and it is also difficult to manage changes in pricing tables.

dsh-analytics is a local analysis plugin: it collects usage from session events, writes it to a local SQLite ledger, calculates costs using a time-aware pricing table, and provides queries via service, agent tool, and JSON API.

What is this

The repository owner of dsh-analytics is hccccc01333, and the GitHub address is:

https://github.com/hccccc01333/dsh-analytics

Its one-sentence positioning is: Agent FinOps / token analytics for DeepSeek Harness. The v1 scope includes Overview, Session drill-down, Cost Engine, and Cache analytics. It performs local analysis on past run records and provides tool cost attribution and budget viewing.

Core Features

Local Usage Ledger

The plugin collects usage from session events into a local SQLite ledger.

Data is stored locally; the documentation states that data does not leave the local machine, and the plugin does not call provider APIs.

Time-Aware Cost Engine

Pricing tables are treated as data, not hardcoded in logic.

dbPath is a required configuration. Built-in default prices are just seed data; they are seeded only when the pricing table is empty to avoid overwriting existing prices on restart.

If custom prices are needed, use pricing or pricingFile; these two are mutually exclusive.

Query Entry Points

ctx.analytics provides the following service methods:

  • overview
  • session
  • sessions
  • models
  • tools
  • pricing
  • budget

The service reads as a separate snapshot, not touching the session store or agent loop.

The plugin also provides the analytics_query agent tool, which can use range_hours to limit the window.

When ctx.webServer exists, read-only JSON routes are also registered:

/api/analytics/overview
/api/analytics/sessions
/api/analytics/models
/api/analytics/tools
/api/analytics/pricing
/api/analytics/budget
/api/analytics/session/<sessionId>

Some routes support the ?hours= query parameter.

Browser Dashboard

The plugin provides a self-contained dashboard at the path:

/analytics

The page includes Overview, Sessions, Reasoning, Agents, Insights, Context Inflation, Token Flow / Models / Cost / Pricing.

The range selector supports 6h / 24h / 7d / 30d / all and provides an EN / Chinese toggle.

Budget and Tool Attribution

Budgets support daily, monthly, and currency configurations and provide month-end spend projections.

Tool costs use step-level attribution: the cost of a model invocation is allocated to the tools called within that step to avoid double counting.

Installation and Activation

Install under the web profile:

dsh plugin --profile web add dsh-analytics

If you already have a local checkout, you can also use a local path:

dsh plugin --profile web add /path/to/dsh-analytics

For local development, you can mount a source overlay:

dsh --profile web --patch ./cordis.yml

Typical Usage

Configuration

At minimum, dbPath needs to be provided, pointing to the SQLite database file.

To customize the pricing table, choose either pricing or pricingFile; these two are mutually exclusive.

Service Queries

The following examples show basic reading methods:

await ctx.analytics.overview({ start, end })
await ctx.analytics.session(sessionId)
await ctx.analytics.budget()

Query by range:

await ctx.analytics.sessions({ start, end })
await ctx.analytics.models({ start, end })
await ctx.analytics.tools({ start, end })
await ctx.analytics.pricing()

Agent Tool Queries

It can be called like this:

analytics_query(query="overview", range_hours=24)

range_hours limits the window ending at the current time; 0 means all time, and the default is 24.

JSON API

When the web server is available, you can directly read the aforementioned /api/analytics/* routes. For example, to view overview or a specific session:

/api/analytics/overview
/api/analytics/session/<sessionId>

Dashboard

Open:

/analytics

Then use the 6h / 24h / 7d / 30d / all range selector to view different pages.

Use Cases and Notes

Suitable for the following use cases:

  • Running multiple sessions or agents in DSH and needing to view cost, cache, model, and tool proportions.
  • Needing to read data such as overview, session, and budget within code.
  • Needing to perform session drill-down and cost viewing in a browser.

Notes:

  • The plugin runs with the current dsh process permissions; you should check the source code, dependencies, and license before installing.
  • License information is not confirmed; please verify it yourself before installing.
  • Web JSON routes are only registered when ctx.webServer exists.
  • The shell-nav integration in the harness client is described as a future item because there is currently no available plugin page slot.
  • The DSH plugin directory is an independent community site with no official affiliation with DeepSeek / HF (Huanfuan), and should not be understood as an official app store.

Conclusion

dsh-analytics organizes tokens, costs, cache, and tool usage during DSH runs into a locally queryable view. If you want to do Agent FinOps in agent development, you can start with its service, agent tool, and /analytics dashboard.

GitHub: https://github.com/hccccc01333/dsh-analytics

Directory Page: Search for dsh-analytics in the DSH plugin directory; this article does not include a specific directory URL because there is no confirmed directory address in the source material.