DeepSeek Harness 插件

dsh-rate-limiter

按 provider 令牌桶主动限速,超限请求在发出前延迟排队而非失败,避免触发上游 429。

跳到安装方式

来源信息

GitHub 仓库
Xidong-AI/dsh-rate-limiter
最近更新
2026年8月18日
分类
用量与账单
GitHub stars
1

安装

默认先复制一段 Prompt,让 Agent 读页面和仓库;需要自己装时再切到命令。

复制这段 Prompt,发给 DSH、Codex 或其他 Agent,让它先读页面和仓库。

请先不要安装。阅读这个 DeepSeek Harness 插件,说明它解决什么问题、会访问哪些文件、网络或密钥,以及如何安装和卸载。

插件页面:https://deepseekplugins.org/zh/plugins/Xidong-AI/dsh-rate-limiter
GitHub:https://github.com/Xidong-AI/dsh-rate-limiter
插件名:dsh-rate-limiter
作者:Xidong-AI
安装命令:dsh plugin --profile web add @xidong-ai/dsh-rate-limiter

确认前不要执行安装命令。

检查来源文件

安装前先看这个插件目录里的 README 和其他文件。

文件资源管理器3 个文件
README.md来源说明 · 只读预览

dsh-rate-limiter

> [English](README.md) | [中文](README.zh.md)

A proactive rate limiter plugin for DeepSeek Harness (dsh): it controls the request rate per provider (token bucket) before model requests are issued, and queues the request with a delay instead of failing when the limit is exceeded — avoiding upstream 429s.

It complements the official dsh-llm-retry (exponential backoff after failure): rate limiting comes first (prevention), backoff comes last (safety net); the two do not interfere with each other.

Features

  • Per-provider token bucket, enforced before the request is sent (proactive prevention)
  • Over-limit requests are queued with a delay instead of rejected (no 429s, no lost requests)
  • Unconfigured providers pass through untouched (zero intrusion)
  • Queued waits honor the abort signal: stopping the user interrupts the wait immediately
  • Hand-written reservation-based token bucket (concurrency-safe), zero third-party rate-limiting dependencies
  • Mounts on agent/request, coexists naturally with dsh-llm-retry

Installation

Install from npm:

dsh plugin --profile web add @xidong-ai/dsh-rate-limiter

> npm registry URLs are case-sensitive; use the lowercase package name.

Or install directly from GitHub:

dsh plugin --profile web add github:Xidong-AI/dsh-rate-limiter

For local development, add the checkout directly:

dsh plugin --profile web add .

After installing, dsh --profile web --dump-config should show the plugin entry:

- id: rate-limiter
  name: @xidong-ai/dsh-rate-limiter
  config:
    enabled: true
    providers: {}

Configuration

Configure the token bucket per provider in the profile's cordis.patch.yml (or this plugin's cordis.patch.yml):

- id: rate-limiter
  config:
    enabled: true
    providers:
      nvidia:
        rate: 2          # tokens/second (long-term average QPS)
        burst: 5         # bucket capacity (allowed burst requests)
      oc-zen:
        rate: 1
        burst: 3
  • rate: refill rate (tokens/second), i.e. the long-term average request rate.
  • burst: bucket capacity, the number of burst requests allowed.
  • Providers not listed are not rate-limited; requests pass through untouched (zero intrusion).
  • enabled: false disables the plugin entirely.

How It Works

The plugin hooks onto the agent/request waterfall: it await next() first to obtain the call config (which carries the provider), then performs a per-provider token bucket check; when tokens are insufficient, it queues the request with a delay (interrupted immediately by the abort signal when the user stops), then returns the config unchanged — it never modifies request content, never changes routing, never swallows errors. It only controls when a request is issued.

The rate-limiting algorithm is a hand-written reservation-based token bucket (concurrency-safe), with zero third-party rate-limiting dependencies.

Relationship with dsh-llm-retry

PluginTimingBehavior
dsh-rate-limiterBefore the request is issuedQueue with a delay when over the limit (prevents 429s)
dsh-llm-retryAfter the request failsExponential backoff retry (safety net)

They mount at different points (agent/request vs agent/request-error) and coexist naturally.

Uninstall

dsh plugin --profile web remove @xidong-ai/dsh-rate-limiter

Development

npm install
npm run typecheck   # tsc --noEmit
npm run test        # vitest run
npm run build       # esbuild transpiles lib/*.ts → lib/*.js

Acknowledgements

Thanks to the Linux.do community for support.