Introduction

When developing or debugging with DeepSeek Harness (DSH), in addition to the conversation content itself, token consumption, cost estimation, and best practices for context management are equally important. The dsh-token-attention plugin aims to provide DSH with a visual token management panel. It does not directly interfere with requests; instead, it records token usage and cost for each conversation segment (aggregated by task/day/week/month), and combines DeepSeek’s peak/off-peak pricing strategy to provide objective recommendations for execution timing, session switching, and Hand-off file preparation.

Core Features

The plugin provides five views in DSH settings: Overview, Sessions, Tasks, Costs, and Settings.

  • Task-based Ledger: Records token consumption for input hits, misses, output, and reasoning, aggregated by task, day, week, and month, and calculates estimated costs.
  • Recommendation Engine: Identifies task types and provides specific suggestions for execution windows, session switching, or writing Hand-offs based on context usage, turns, hit rate, cost, and model mix.
  • Attention KPIs: Provides key metrics for each session, including attention score, hit rate, context usage rate, and compression count.
  • Peak/Off-Peak Pricing Support: Supports DeepSeek’s peak/off-peak pricing (half-price windows), such as peak hours 9:00-12:00 and 14:00-18:00.
  • Multi-Model Breakdown: Breaks down costs and hit rates by model dimension (e.g., deepseek-v4-flash / pro / grok).
  • Data Export: Supports exporting ledgers in Markdown and CSV formats, and provides a Hand-off template.
  • Zero-Dependency Storage: Uses local SQLite for data storage, without network requests.

Installation and Enablement

After publishing via npm, add the plugin using the official installation command:

dsh plugin --profile web add dsh-token-attention

After installation, restart DSH and open the “Token Management” panel in Settings. Data files are stored in DSH_HOME/token-attention/token_records.db.

Working Principle

The plugin collects data by subscribing to DSH’s session/event stream and writes normalized records to SQLite. At startup, it performs replay using an idempotent last_seq cursor to replay existing sessions. Subsequently, it performs an incremental aggregation every hour, writing to the daily_agg table, and a full rebuild daily to correct data.

For metrics such as context usage, the plugin preferentially reads DSH’s built-in session-projection and session-stats data sources (such as contextPressure.projectedTokens). If the source data is unavailable, it uses its own calculated results.

Configuration

Settings in the panel can be edited and saved to SQLite, including the model pricing table (default flash hit price of 0.05 per million tokens), peak/off-peak periods (default 9-12, 14-18), context usage recommendation threshold (default 70%), turn recommendation threshold (default 40), and hit rate recommendation threshold (default 40%).

Notes

  • Environment Requirements: Requires Node.js version >= 24.
  • Not a Rate-Limiting Tool: This plugin is not a cost-saving tool. It does not rate-limit or cancel requests; it only provides facts and recommendations.
  • Local Storage: All data is stored in local SQLite. The dispose method cleans up timers and SQLite connections.

Summary

By making token consumption and costs transparent and providing execution recommendations based on DeepSeek’s pricing mechanism, dsh-token-attention helps developers more finely manage the agent development process. Its local SQLite storage ensures data privacy and independence.