DSH Task Cost Plugin: Estimating and Controlling Task Costs in DeepSeek Harness

Introduction

When running tasks in DeepSeek Harness (DSH), not knowing the approximate cost in advance can easily lead to budget overruns. This is especially true for batch tasks or long-running sessions, where actual costs often deviate significantly from initial expectations. Existing approaches typically only allow you to review bills after the fact, making it impossible to estimate and control costs before a task begins.

The task cost plugin introduced below provides an integrated panel directly in the chat interface, combining cost estimation + budget control + actual charges to help you understand costs at the moment a task is dispatched and to offer actionable options when the budget is exceeded.

Plugin Overview

This is an official DSH plugin maintained by GYC159159, with the ID dsh-task-cost and version 0.1.0. It reads the current session’s token count, prompt length, and model pricing to estimate the cost range of a task, then displays key metrics in a floating mini-panel within the chat interface.

Core Features

The plugin adds a “¥ Task Cost” entry in the chat interface. Clicking it reveals six data fields (unit: CNY):

  • Estimated Cost: Available after a task is dispatched and estimation is complete
  • Estimation Tolerance: Formatted as -1.50 / +1.50
  • Actual Cost: Populated after task completion (real charge) or cancellation (¥0.00)
  • Balance: Always displayed; read directly from the DeepSeek account balance
  • Budget: Editable when no task is active; saved before dispatching a task
  • Budget Tolerance: Defines the upper/lower deviation allowed around the budget

In a session with no active task, all fields except Balance, Budget, and Budget Tolerance display a dash (—).

Estimation Logic

After a user submits a task (not a / command) in the input field, the plugin executes the following steps:

  1. The Host uses tokenMeter to retrieve the current context tokens, then estimates the number of steps and per-step output tokens based on the prompt’s CJK character count, code blocks, and verb intensity.
  2. Calculate total input and total output:
    - Total input ≈ steps × (context + prompt) + steps²/2 × per-step output × 0.7
    - Total output ≈ steps × per-step output
  3. Convert to currency using model unit prices from prices.json, producing a center value + variance range; historical actual costs are calibrated at 32%.
  4. Once the estimate is ready, the mini-panel pops up automatically.

Budget Control

The plugin checks whether the estimated range falls within [Budget − Budget Tolerance, Budget + Budget Tolerance]:

  • If fully within range → marked as auto, no interruption to the user.
  • If exceeded → the mini-panel opens automatically and presents options (ordered from least to most expensive: run with current model / economy mode / switch to a cheaper model).
  • The user can choose “Proceed despite over-budget”, “Use the economy plan”, or “Cancel task”.

Upon task completion:
- completed → displays the actual charge
- aborted/interrupted or user cancellation → displays ¥0.00

Data & API

The plugin exposes the following Host routes (same origin):

  • GET /task-cost/state?sessionId=…
  • POST /task-cost/budget
  • POST /task-cost/decision
  • GET /task-cost/status

State is persisted at <DSH_PROFILE_DIR>/data/task-cost-state.json, recording budget and task info per session, with a retention window of 7 days / 60 sessions.

The pricing table lives in prices.json within the package. Changes take effect on the next estimation run.

Estimation Disclaimer

This is an estimate, not an invoice. Actual costs are determined by accumulating usage from each assistant/message. If a provider does not return usage data, the reported actual cost will be lower than the true cost.

Installation & Activation

Install with the following command:

dsh plugin add github:GYC159159/DSH

After installation, the plugin automatically adds a “¥ Task Cost” button at the chat interface entry point.

Typical Usage

  1. In a session, click “¥ Task Cost” and enter or confirm a budget (e.g., ¥0.02 ± ¥0.01).
  2. Submit a task in the input field; the plugin automatically pops up the mini-panel showing the estimated cost and range.
  3. If the estimate exceeds the budget, the mini-panel presents three-tier options—choose “Use the economy plan” or “Cancel task”.
  4. After the task ends, check whether the “Actual Cost” is close to the estimate.

Use Cases & Cautions

Ideal for sessions that require cost control and frequent task execution, particularly scenarios involving budget-based task allocation or evaluating the cost of individual tasks.

Note: The plugin runs with the current DSH process permissions. Before installing, review the source code and license (MIT), and confirm there are no risks before use.

Summary

The task cost plugin provides DeepSeek Harness with a complete cost management workflow spanning estimation → control → verification. Through a simple entry point and a floating mini-panel, it makes budgets and actual costs transparent at a glance, helping you make more informed decisions before a task even begins.

For more details and source code, see:

  • GitHub: https://github.com/GYC159159/DSH
  • Plugin directory: https://www.skillhub.cn/plugins/GYC159159/DSH
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye