Introduction

DeepSeek Harness (DSH) is a plugin-based agent development framework. When developing agents or using DeepSeek models, tracking token consumption and associated costs for each conversation is a key part of cost control. Although models report usage data, DSH does not natively provide session-level aggregation or cost display in currency. The dsh-session-cost plugin parses usage data from session logs and provides per-session token usage and estimated costs in Chinese yuan (CNY).

Plugin Overview

This is a DSH plugin maintained by jyhn-hunao under the MIT License. It does not rely on build tools and is implemented in pure JavaScript. It can read token statistics reported by models and convert them into estimated costs in CNY for display.

Core Features

  1. Session-level statistics: Aggregates token usage reported by models per session.
  2. Tool invocation: Provides the session_cost tool, allowing an agent to query the consumption of one or more conversations (if sessionIds is not provided, it queries the current conversation by default).
  3. Command-line queries:
    • /session-cost [sessionId]: View accumulated consumption for the current conversation or a specified session.
    • /session-cost-config: View the current price table.
  4. Sidebar display: Shows accumulated session cost in the sidebar (requires specific environment support).

Installation and Enablement

Use the officially provided installation command to add the plugin:

dsh plugin --profile <name> add github:jyhn-hunao/dsh-session-cost

On first installation, if pnpm warns that build scripts are not authorized, add allowBuilds: dsh-session-cost: true to pnpm-workspace.yaml in the profile and retry. This warning can be safely ignored because this plugin does not actually have any build steps.

Usage

View Consumption

Users can check consumption via the command line:

/session-cost                 # 查看当前对话的累计消耗
/session-cost <sessionId>     # 查看指定会话的累计消耗

View Price Table

View the current price table:

/session-cost-config

Let the Agent Query

When asking the agent to query, simply say “Check how much each conversation has cost.” The agent will automatically invoke the session_cost tool.

Price Table Configuration

The default price table only includes standard DeepSeek rates. Starting from 2026-08-17, DeepSeek enforces peak/off-peak pricing, with higher rates during peak periods. The default values are estimates based on standard rates, so override them with your actual billing rates.

In cordis.patch.yml for the profile, override the entire config line by id (the whole table is replaced; models not listed fall back to *):

- patch:
    - id: session-cost
      config:
        pricing:
          deepseek-chat: { inputPerM: 2, cacheReadPerM: 0.5, cacheWritePerM: 2, outputPerM: 8 }
          deepseek-reasoner: { inputPerM: 4, cacheReadPerM: 1, cacheWritePerM: 4, outputPerM: 16 }
          '*': { inputPerM: 2, cacheReadPerM: 0.5, cacheWritePerM: 2, outputPerM: 8 }

Known Dependencies and Limitations

  • Data source: Costs are based on usage reported by models in session logs (assistant/message / assistant/chunk), which shares the same source as DSH’s built-in token statistics. The data is accurate and not an estimate.
  • Sidebar display limitation: The inline amount UI in the sidebar requires the official repository to support the sidebar.workspaces.sessionRow slot. The stock DSH does not yet include this slot, so the sidebar amount may silently not appear on stock builds (the session_cost tool and the /session-cost command are not affected). To enable sidebar display, install a DSH build that includes the corresponding slot.

Summary

This plugin addresses the need for cost tracking in agent development by parsing token usage data from session logs and providing an intuitive cost display. After installation, session costs can be viewed via commands or configuration.

Plugin directory:
https://www.skillhub.cn/plugins/jyhn-hunao/dsh-session-cost

Source repository:
https://github.com/jyhn-hunao/dsh-session-cost