dshbase

插件目录 / Developer / dsh-agent-rate-limit

dsh-agent-rate-limit

已验证 · 实测可装 zhourenke

✓ 持续维护 基于 5 个官方 DSH 包

查看 GitHub ↗ ← 返回插件目录

0Stars
0Forks
0未关闭 issue
—语言
2026-08-22最近推送
跨平台平台

功能简介

Developer 类别的 DeepSeek Harness 插件。

✅
我们的评价
可用 — 实测通过,早期项目

Developer 类别的 DeepSeek Harness 插件。 实测能干净安装、正常启动。早期项目,但功能可用。

「已验证」表示我们的自动化 CI 在干净 profile 里实际执行了 dsh plugin add 并启动成功——仅此而已。功能描述与版本兼容性均为作者声明。这不是安全审计,也不代表对第三方代码的背书。

README

@zhourenke/dsh-agent-rate-limit

A DSH agent loop rate limiter that prevents TPM (Tokens Per Minute) and RPM (Requests Per Minute) limit violations by intercepting the LLM streaming pipeline and adding adaptive delays between requests. Also retries HTTP 429 responses with escalating backoff.

Installation

Copy the package to your DSH profile's node_modules:

# From the repo root
Copy-Item -Recurse -Force .\dsh-agent-rate-limit $env:USERPROFILE\.dsh\profiles\web\node_modules\@zhourenke\dsh-agent-rate-limit

Or use a directory junction for development:

New-Item -ItemType Junction -Path "$env:USERPROFILE\.dsh\profiles\web\node_modules\@zhourenke\dsh-agent-rate-limit" -Target "C:\path\to\dsh-agent-rate-limit"

Usage

Add to your agent preset:

- id: agent-rate-limit
  name: '@zhourenke/dsh-agent-rate-limit'

Configuration

Key Default Description
windowMs 60000 Sliding window size in milliseconds (60s).
tpmLimit 1200000 TPM (Tokens Per Minute) limit. Default matches Alibaba Cloud Bailian deepseek-v4-flash.
rpmLimit 15000 RPM (Requests Per Minute) limit.
safetyFactor 0.8 Safety factor (0.8 = use 80% of the limit, leaving 20% buffer).
maxBackoffMs 30000 Maximum backoff delay in milliseconds (30s).
retryOn429 true When true, HTTP 429 responses are silently retried with escalating backoff.
maxRetries 5 Maximum consecutive 429 retries per burst before giving up.
verbose false When true, log per-request details (delay, token recording, retry attempts).

Check status

Type /agent-rate-limit in the chat input to see current plugin status and configuration.

How it works

Token tracking

  1. Token recording: After each successful model call, the plugin records the exact token count from the API's usage chunk — far more accurate than heuristic estimation.
  2. Sliding window: A 60-second FIFO queue tracks recent token consumption. Before each request, the plugin checks if the current window is approaching the TPM or RPM limit and delays accordingly.
  3. Input estimation: For the pre-request delay calculation, the plugin uses the average of the last 3 actual input token counts from the API. Falls back to heuristic estimation (CJK: ~1.5 chars/token, others: ~3.5 chars/token) only for the very first request.

Error recovery

When a rate-limit error is detected (HTTP 429), the plugin:

  1. Increments the retry count for the current burst
  2. Returns { kind: 'retry' } to retry transparently
  3. Applies escalating backoff: 2s → 4s → 8s → 16s → 30s (capped at maxBackoffMs)
  4. Gives up after maxRetries consecutive failures and surfaces the error
  5. Resets the retry counter on success

Rate limit detection

The plugin detects HTTP 429 by checking the error's statusCode, code, and message for patterns like rate limit, too many requests, tpm, rpm, quota, throttl, and 429.

Credits

Built for DeepSeek Harness.

安装

🧩 让 Agent 自动装(推荐)

装一次目录插件,之后本站所有插件都能让 DeepSeek Harness 自动找、自动装:

dsh plugin add dshbase-catalog

然后对 agent 说「帮我装 dsh-agent-rate-limit」,它会在目录里找到并自动安装。文档:dshbase-catalog · 已验证场景包。

该插件是 GitHub 源码(未发 npm)——直接从仓库装:

Web profile:

dsh plugin --profile web add github:zhourenke/dsh-agent-rate-limit

Headless(CLI)profile:

dsh plugin --profile headless add github:zhourenke/dsh-agent-rate-limit

实测报告

验证通过:从 GitHub 源码完成 L1 安装 + L2 加载 + L3 运行(dsh 0.1.0-rc.6)。

安全:尚未扫描——我们的每日静态扫描将很快覆盖它。

分享徽章

Developer 里更多

浏览全部 7819 个插件 →