Introduction¶
DeepSeek V4 employs peak-valley pricing: during peak hours on weekdays, output prices are twice the valley rates. For agent developers running long sessions on DeepSeek Harness (DSH), executing the same task during peak hours doubles the output overhead; while a significant portion of the output consists of compressible content such as pleasantries and hedging phrases.
DSH’s philosophy is “everything is a plugin,” and time-based behavior is ideally suited for handling via plugins. The dsh-peak-cost-mode introduced below does exactly this: it automatically instructs the model to switch to ultra-concise output during peak hours to save tokens, and calculates and displays the savings in terms of token count and RMB based on DeepSeek’s pricing.
What is it¶
dsh-peak-cost-mode is a DSH web plugin, created by moon09300731, licensed under MIT, with the current version number in package.json being 0.4.0.
One-sentence positioning: A DeepSeek peak-valley pricing savings plugin—automatically switches to “caveman” ultra-concise output during peak hours to save tokens, features a title bar badge + switch reminders, and calculates saved tokens and RMB based on DeepSeek pricing.
It solves two problems: first, peak-hour costs, by reducing token consumption through output compression; and second, the visibility of “how much was actually saved”—the plugin intercepts and measures the real token usage of every streaming call, rather than just providing a toggle.
Core Features¶
Peak Detection¶
The plugin checks Beijing Time (UTC+8, no Daylight Saving Time) against the DeepSeek V4 peak-valley pricing table:
| Time (Beijing Time) | Tier | Price |
|---|---|---|
| Mon-Fri 09:00–12:00 | Peak | ×2 |
| Mon-Fri 12:00–14:00 | Valley | ×1 |
| Mon-Fri 14:00–18:00 | Peak | ×2 |
| Mon-Fri 18:00–Next 09:00 | Valley | ×1 |
| Sat-Sun All Day | Valley | ×1 |
Regarding the detection cycle: the client client.js polls the status interface every 10 seconds; the host side checks the Beijing time cycle. There are inconsistent statements in the README (one states a check every 30 seconds, another states a 10-second timer). This article makes no assertion; refer to the source code.
Caveman Output during Peak Hours¶
Upon entering a peak window, the plugin injects a prompt segment named “Peak Cost Mode” (order 60), instructing the model to reply in an ultra-compressed “caveman” style: it discards pleasantries and hedging phrases but retains technical content such as code, commands, API names, file paths, precise error strings, and numbers word-for-word; security warnings and irreversible operation confirmations are never compressed.
Badge and Switch Notifications¶
There is a persistent status badge on the right side of the conversation header:
- Peak Hours: Red “Peak ×2 · Saving”
- Voluntarily Saving: Green “🟢 Valley · Voluntarily Saving”
- Other Times: Green “Valley ×1”
Hovering over the badge displays the peak-valley window, multiplier, Beijing time, and the next switch time; clicking opens the savings report.
A toast notification pops up every time the tier switches:
- Valley → Peak: “Liang Wenfeng is here, speak less and do more.”
- Peak → Valley: “Liang Wengu is here, everything is normal.”
Voluntary Saving during Valley Hours (since 0.3.0)¶
You can also voluntarily save during valley hours: click “🟢 I Want to Save Money!” in the bottom right of the savings report to inject the same caveman prompt segment and continue tracking. These waves are counted separately from official peak hours using source: voluntary vs. source: peak.
This switch persists across restarts and peak-valley cycles: entering peak automatically merges into peak measurement, and leaving peak automatically restores voluntary saving; you can stop saving at any time by clicking “✋ Stop Saving” in the report.
Savings Measurement and Display¶
The measurement logic (since 0.3.0) consists of three steps:
- The plugin intercepts every streaming model call (
llm/stream) and records the real token usage—input miss / cache hit / output—listed by model. - Estimate savings using
saved tokens ≈ actual output tokens × r/(1−r), whereris the compression ratio (default 0.6, configurable 0–0.9). - Convert to RMB based on DeepSeek peak output prices (peak price = valley ×2; examples: V4-Flash output ¥9.0/M, V4-Pro output ¥27.0/M).
Note: Only the output side is counted. Compression does not change input tokens or cache hits (the platform’s prompt-reuse cache rate is unrelated to the plugin); input-side cache delta is only for reference in /stats and not included in savings.
Savings data appears in four places: real-time count in the header badge, environment readings above the composer (conversation.composer.dock), the switch toast, and the savings report panel. The report panel displays the current wave / today / accumulated tokens and RMB, a breakdown by model (counterfactual output → actual output → savings), and peak/voluntary splits. It can be reset via POST /api/peak-cost/reset. Data is persisted by wave to ${DSH_HOME:-~/.dsh}/dsh-peak-cost-mode/stats.json (v3 format) and retained across restarts.
Installation and Enablement¶
dsh plugin --profile web add dsh-peak-cost-mode
# or install from GitHub:
dsh plugin --profile web add github:moon09300731/dsh-peak-cost-mode
After installation, you need to restart dsh web and perform a hard refresh in the browser for the badge and report to appear.
Note: The community plugin directory provided below is an independent site with no official affiliation with DeepSeek or 幻方; it is not the official app store.
Configuration¶
Optional configuration file located at ${DSH_HOME:-~/.dsh}/dsh-peak-cost-mode/config.json:
{
"saveRatio": 0.6,
"baseCacheHitRate": 0.5,
"multiplier": 2,
"peakWindows": [
{ "start": 9, "end": 12 },
{ "start": 14, "end": 18 }
],
"weekendValley": true,
"prices": {
"deepseek-v4-flash": { "hit": 0.05, "miss": 1.5, "output": 4.5 },
"deepseek-v4-pro": { "hit": 0.15, "miss": 4.5, "output": 13.5 }
}
}
Fields:
saveRatio: Output compression ratio in caveman mode, default 0.6, range 0–0.9baseCacheHitRate: Default 0.5multiplier: Peak multiplier, default 2peakWindows: Peak windows in Beijing Time, default[{9,12},{14,18}]weekendValley: Default true, meaning weekends are counted as valley hours all dayprices: Set valley prices by model (¥ / million tokens); precise model keys override built-in flash/pro defaults
The prices will expire; verify against DeepSeek’s official pricing page before use. The savings displayed in the UI are estimates, not a bill.
Typical Usage¶
- Install the plugin, restart
dsh web, and perform a hard refresh of the browser page. - During valley hours, click the green badge to open the savings report, and click “🟢 I Want to Save Money!” in the bottom right to enable voluntary saving; click “✋ Stop Saving” in the report when not needed.
- After entering peak hours, the plugin switches automatically; no action is needed. Click the header badge anytime to view current wave / today / accumulated savings.
- To reset statistics, use
POST /api/peak-cost/reset.
Interfaces and Development Verification¶
The plugin exposes the following interfaces on the host side:
GET /api/peak-cost/state
GET /api/peak-cost/stats
POST /api/peak-cost/voluntary?active=true|false # persistent voluntary saving toggle
POST /api/peak-cost/reset
The client client.js polls /api/peak-cost/state every 10 seconds and mirrors the snapshot to the localStorage key dsh.peakCost.v1.
Development and Verification:
npm test # node --check + unit tests
node scripts/verify.mjs # independent recalculation of /api/peak-cost/stats, PASS means accounting is correct
Suitable Scenarios and Notes¶
Suitable Scenarios:
- DSH web users who primarily run long sessions on DeepSeek V4, where output tokens make up a large portion
- Frequent use during weekdays during the day (peak hours), willing to trade simpler output for lower cost
- Want to know exactly how many tokens and how much money were saved, rather than just having a toggle
Notes Before Use:
- The prompt segment is registered in the host scope, so any savings mode applies to all deployed sessions. If you need compression for a single session only, you need to use the dynamic-plugin variant.
- The displayed savings numbers are estimates (counterfactual: the exact uncompressed output is unknown), clearly marked in the UI; the displayed savings are estimates, not a bill.
- Savings are only counted on the output side; compression does not change input tokens or cache hits.
- The
priceswill expire; verify against DeepSeek’s official pricing page. - The plugin runs with the permissions of the current
dshprocess; check the plugin source code and license before installing (this project is MIT).
Summary¶
dsh-peak-cost-mode makes peak-valley pricing fully automated: it automatically compresses output during peak hours and allows voluntary saving during valley hours. The saved tokens and RMB are all displayed in the report, and the data persists across restarts. If you run DeepSeek on DSH, give it a try.
- Directory: https://www.skillhub.cn/plugins/moon09300731/dsh-peak-cost-mode
- GitHub: https://github.com/moon09300731/dsh-peak-cost-mode