dsh-peak-gate: Peak/Off-Peak Time-of-Use Pricing Control for DeepSeek

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:

  1. Block heavy tasks during peak hours: Intercepts time-consuming task steps in the agent/pre-step hook.
  2. Limit tool budgets during peak hours: Restricts the maximum number of steps for tool calls in a single turn.
  3. Compress output during peak hours: Forces the maxTokens limit to be capped at a reduced maximum.
  4. Streamline output during peak hours: Modifies the systemPrompt to require the model to reduce redundant output during peak hours.
  5. 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.

  1. Place Source Code
    Place the plugin source code folder dsh-peak-gate-src into the Profile’s vendor directory:
    <DSH_HOME>/profiles/web/vendor/dsh-peak-gate-src
  1. Modify Configuration
    Edit <DSH_HOME>/profiles/web/package.json, add a local link in dependencies, and add dsh-peak-gate to the dsh.profile.bundles list:
    {
      "dependencies": {
        "dsh-peak-gate": "link:vendor/dsh-peak-gate-src"
      },
      "dsh.profile.bundles": [
        "dsh-peak-gate"
      ]
    }
  1. Execute and Restart
    Run pnpm install to install dependencies, then restart dsh web.

  2. Configure Namespace
    Add the peak-gate namespace configuration to profiles/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

  1. Online Source: Fetched from NateScarlet/holiday-cn by default. It tries jsDelivr, raw.githubusercontent, and gh-proxy in order, fetching only the current year’s data.
  2. Disk Cache: Cached to <DSH_HOME>/data/peak-gate/holidays-cn.json by default. It will not re-fetch for 30 days. If the network fails, it uses the old cache and issues a warning.
  3. Built-in Fallback: Includes DEFAULT_HOLIDAYS in the code, supporting offline use.
  4. 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, and autoHolidayCalendar: false simultaneously.

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 schemastery and @deepseek-ai/dsh-llm dependencies 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

羽毛球分组比赛记分
小程序二维码

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

Xiaoye