Xidong-AI/dsh-rate-limiter

DeepSeek Harness的主动速率限制器插件。

Project Overview项目介绍

This is a DSH-native proactive rate limiting plugin built exclusively for DeepSeek Harness, designed to prevent upstream 429 “too many requests” errors by controlling request rates per model provider before any requests are sent out. When a request exceeds the per-provider configured rate limit, it is queued with a delay instead of being rejected, so no user requests are ever lost. It can be installed via the official DSH plugin command from the npm registry, directly from the GitHub repository, or added as a local development package for testing.

After installation, users need to configure token bucket parameters for each provider that requires rate limiting in their DSH profile configuration file. Each provider requires two parameters: the token refill rate in tokens per second, which sets the long-term average request QPS, and the burst capacity, which sets the maximum number of concurrent burst requests allowed. Providers that are not listed in the configuration are not rate limited at all, and pass through untouched with zero intrusion into your existing workflow. This plugin is ideal for any DSH user that needs to avoid hitting model provider rate limits when making frequent requests.

This plugin uses a custom hand-written reservation-based concurrency-safe token bucket algorithm, and does not depend on any external third-party rate limiting libraries. It only hooks into the DSH agent/request waterfall lifecycle, and never modifies request content, changes routing logic, or swallows errors. It only controls when a request is issued to the upstream provider. Queued requests honor the user abort signal immediately: if you stop the request generation mid-wait, the wait is canceled right away. The plugin is released under the permissive MIT open source license, so anyone can use, modify, or redistribute it freely for any purpose.

这是一款专为 DeepSeek Harness 开发的原生速率限制插件,采用令牌桶算法实现每个模型提供商级别的主动限流,在模型请求发出前检查速率,超出限制的请求排队延迟处理,而非直接返回失败,从根源上避免上游返回 429 错误。它可与官方的 dsh-llm-retry 插件配合,前者事前限流预防,后者出错后退避重试,二者互不干扰可互补工作。用户可通过 dsh 插件命令从 npm 或 GitHub 安装该插件。

安装完成后,用户需要在配置文件中对每个需要限流的模型提供商单独配置令牌桶参数,包括每秒补充的令牌速率(即长期平均请求 QPS)和令牌桶容量(即允许的突发请求数)。未在配置中列出的提供商,请求会直接通过不做任何限制,对原有工作流无侵入。该插件适合需要控制大模型请求频率、避免触发提供商限流的 DSH 用户使用。

该插件使用自研的基于预留的并发安全令牌桶算法实现,不依赖任何第三方限流库,仅挂载在 agent/request 生命周期钩子上,不会修改请求内容、改变路由或吞掉错误,仅控制请求发出的时机。排队等待的请求会响应用户中断信号,用户中断操作会立即停止等待。该插件采用 MIT 许可证开源,可免费使用修改。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 3 stars - very few users, little community feedback星标只有 3,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

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

把 Xidong-AI/dsh-rate-limiter 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-rate-limiter

English | 中文

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: 0.5        # tokens/second (long-term average QPS)
        burst: 1         # bucket capacity (allowed burst requests)
      sensenova:
        rate: 0.02778
        burst: 1
  • 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.

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev PocketCode 下一个 Next dsh-plugin-open-with →