DeepSeek’s billing adopts a peak/off-peak time-based pricing strategy, with prices doubling during peak hours. For developers building agents using DeepSeek Harness (DSH), running a large number of tasks during peak hours without control can rapidly increase costs. The dsh-peak-gate plugin aims to solve this problem. It uses code-level hooks to automatically limit task execution, compress output budgets during peak hours, and provides a one-click bypass command.
Plugin Positioning & Maintainer¶
- Name:
dsh-peak-gate - Positioning: A DSH host-side plugin responsible for intercepting or adjusting requests based on time rules on the host side.
- Maintainer: CNyaotian-Lunar
- License: MIT
- Nature: A community-developed plugin, unrelated to the official DeepSeek / DeepSeek Harness.
Core Functions¶
The plugin primarily enforces controls at the following five levels:
- Block heavy tasks during peak hours: Intercepts time-consuming task steps in the
agent/pre-stephook. - Limit tool budgets during peak hours: Restricts the maximum number of steps for tool calls in a single turn.
- Compress output during peak hours: Forces the
maxTokenslimit to be capped at a reduced maximum. - Streamline output during peak hours: Modifies the
systemPromptto require the model to reduce redundant output during peak hours. - One-click bypass command: Provides a specific command to force-approve specific requests during peak hours.
Installation & Activation¶
This plugin is not installed via the plugin marketplace but is integrated through Web Profile dependency mounting. Ensure your DSH version is 0.1.7 or higher.
- Place Source Code
Place the plugin source code folderdsh-peak-gate-srcinto the Profile’svendordirectory:
<DSH_HOME>/profiles/web/vendor/dsh-peak-gate-src
- Modify Configuration
Edit<DSH_HOME>/profiles/web/package.json, add a local link independencies, and adddsh-peak-gateto thedsh.profile.bundleslist:
{
"dependencies": {
"dsh-peak-gate": "link:vendor/dsh-peak-gate-src"
},
"dsh.profile.bundles": [
"dsh-peak-gate"
]
}
-
Execute and Restart
Runpnpm installto install dependencies, then restartdsh web. -
Configure Namespace
Add thepeak-gatenamespace configuration toprofiles/web/cordis.patch.yml. DSH version 0.1.7+ supports hot-reloading, so it takes effect without a restart.
Billing Logic¶
The plugin’s logic is based on Beijing Time, using the “read UTC fields after UTC+8 shift” method. It does not rely on the local machine’s timezone, thus is unaffected by Daylight Saving Time.
According to DeepSeek’s official pricing rules:
| Time Period (Beijing Time) | Price |
|---|---|
| Monday to Friday 09:00–12:00, 14:00–18:00 | Peak ×2 |
| Other times, all-day weekends, all-day Chinese public holidays | Off-peak ×1 |
Automatic Calendar for Public Holidays¶
The plugin includes a complete calendar of Chinese public holidays for 2026, supporting online updates and local caching.
Multi-layer Cache & Verification¶
- Online Source: Fetched from
NateScarlet/holiday-cnby default. It tries jsDelivr, raw.githubusercontent, and gh-proxy in order, fetching only the current year’s data. - Disk Cache: Cached to
<DSH_HOME>/data/peak-gate/holidays-cn.jsonby default. It will not re-fetch for 30 days. If the network fails, it uses the old cache and issues a warning. - Built-in Fallback: Includes
DEFAULT_HOLIDAYSin the code, supporting offline use. - Data Validation: The number of holidays in a single year must be between 15 and 45 days. Cache timestamps in the future are judged as corrupted and will trigger a re-fetch.
Make-up Workday Rules¶
According to the official supplementary explanation on 2026-09-19:
* Make-up workdays are billed as off-peak: Nationally designated make-up workdays (e.g., Saturdays) are unconditionally billed at the off-peak rate, without restoring peak pricing.
* Cache Merging: The workdays in the cache and the built-in DEFAULT_MAKEUP_DAYS are merged into the calendar.
Configuration Options¶
holidays: Append custom calendars (default is the built-in table).useBuiltinHolidays: Whether to merge the built-in table (set to false to narrow the scope).autoHolidayCalendar: Disable network fetching.holidayCalendarUrls,holidayCacheMaxAgeDays,holidayFetchTimeoutMs,holidayCachePath.
⚠️ Note: To use only a custom calendar, you must set
holidays: [],useBuiltinHolidays: false, andautoHolidayCalendar: falsesimultaneously.
Use Cases & Notes¶
- Use Cases: Developers who need strict control over DeepSeek API Token spending and wish to avoid executing non-critical tasks during peak hours.
- Runtime Environment: Runs with the current DSH process permissions. Ensure
schemasteryand@deepseek-ai/dsh-llmdependencies are available. - Ecosystem Note: The DSH philosophy is “everything is a plugin”. This plugin comes from the community directory SkillHub and has no affiliation with DeepSeek.
Source Code & Documentation¶
- GitHub Repository: https://github.com/CNyaotian-Lunar/dsh-peak-gate