Introduction¶
DeepSeek Harness (DSH) is built around the core philosophy of “everything is a plugin,” allowing developers to extend functionality flexibly. In long sessions or complex tool-calling scenarios, input Token consumption is often a significant cost item. The dsh-token-frugal plugin is designed to compress tool outputs at the source, reducing input Token cost through tiered savings strategies and session memory matching, without affecting core capabilities.
Plugin Overview¶
- Name: dsh-token-frugal
- Author: xuzihao66
- License: MIT
- Tagline: Reduces DeepSeek Harness long-session input Token cost through source-side tool output compression, tiered savings strategies, and session memory matching.
Core Features¶
The plugin extends five key points in Harness’s event stream:
-
Tool Result Compression (
tools/post-execute)
Compresses each accepted tool result before it is logged. The processing pipeline first applies lossless, structure-aware transformations, then omits the head/tail according to budget and marks the restoration path. -
Agent Tool Directory Management (
agent/created)
Usesctx.tools.restrict()to hide configured tools and restrict them to a specific agent context. The plugin logs tool removal/addition blocks and writes the changes into workspace memory documents. -
Workspace Memory Matching (
agent/inbox/claimed)
When handling a new message, matches it against workspace memory documents. Injects the best-matching fragment viaagent.inject()and triggers theagent/inbox/splicedevent, instead of rewriting history. -
Tiered Savings Control Panel (
conversation.composer.dock)
Provides a control panel below the conversation editor. The savings strategy is divided into three levels:- Basic: Lossless; cleans only whitespace and control characters.
- Moderate: Collapses repeated lines and counters; content can be restored losslessly.
- Aggressive: Truncates and rewrites overly long results, involving information trade-offs.
Each level has a corresponding switch, and changes take effect immediately without restarting the session.
-
Savings Statistics Page (
settings.section)
Provides a statistics page in Settings, reporting actual saved Tokens and metrics. Price estimation follows Harness’s heuristic rule of 4 characters ≈ 1 Token.
Usage¶
After enabling the plugin, the control panel appears below the dialog box and displays the number of enabled savings options. Clicking the panel expands the three level categories, where switches control specific strategies. Switching a toggle applies immediately to the current session and persists the configuration.
For detailed statistics, go to “Settings” -> “Token Savings”. The page displays savings data for the current process and historical cumulative totals, including removed character count, saving ratio, and per-tool breakdowns.
Technical Details¶
- Persistent Storage: Plugin state and mode configuration are stored in
dsh-token-frugal.state.json, located next to the configuration file. - Price Estimation: The statistics page uses the same heuristic as Harness (4 characters ≈ 1 token) for estimation.
- Communication Mechanism: The plugin communicates between Client and Host via HTTP routes.
- Version Updates: The current version is 2.2.0. v2.0.5 fixed an abnormal display caused by an empty
source.kind; v2.0.4 introduced the tiered panel and statistics page.
Notes¶
- Directory Statistics: Tool directory savings values are calculated per request, not as cumulative totals.
- History Records: If the configuration file is not found, historical cumulative data is retained in memory only.
- Permission Scope: The plugin runs with the current DSH process permissions; it is recommended to review the source code and license before installation.
Summary¶
dsh-token-frugal provides a complete solution for tool output compression and memory retrieval. With visual tiered control and real-time statistical feedback, it helps developers effectively control Token cost in long sessions without sacrificing core functionality.