Introduction¶
When developing agents with DeepSeek Harness (DSH), system prompts, tool definitions, and conversation history turns rapidly consume the context window, leading to prompt truncation or degraded inference quality. Currently, the DSH community lacks a standalone tool for quick estimation of context usage. The dsh-context-budget plugin introduced below aims to solve this problem.
What It Is¶
dsh-context-budget is a DSH plugin that estimates the context usage of an application in the current turn: it maps the character counts of the system prompt, tool definitions, and historical turns into token estimates, provides the window occupancy ratio along with truncation risk warnings, and integrates with the bundled rate card to display the per-input cost.
The plugin is maintained by feely0208 and is categorized under model inference.
Core Features¶
- Context Usage Estimation: Given the system prompt character count, tool definition character count, and number of history turns as input, it outputs a token estimate, window occupancy ratio, and truncation risk warning.
- Rate Integration: Calculates the per-input cost based on the bundled rate card.
- Estimation Disclaimer: Token values are estimates (DeepSeek has not published its tokenizer); refer to the official
usagefield for exact figures.
Installation & Activation¶
In an environment where DSH is already installed, run:
dsh plugin --profile web add @deepwhale-cn/dsh-context-budget
You can also install it via npm or from a local repository:
npm i @deepwhale-cn/dsh-context-budget
dsh plugin install ./
Typical Usage¶
Run the estimation command from the command line:
npx @deepwhale-cn/dsh-context-budget --type budget --system_chars 3200 --tools_chars 1800 --history_turns 20
Use demo mode:
npx @deepwhale-cn/dsh-context-budget --demo
Use Cases & Notes¶
Ideal for quickly evaluating context usage and cost during development and debugging. The plugin runs with the privileges of the current DSH process; review the source code and license before installing.
In Brief¶
dsh-context-budget provides a quick estimation pipeline from characters to tokens and costs, helping developers mitigate the risk of context overflow during development. See the catalog page and GitHub repository for the project homepage.