返回目录
模型与 MCP 插件

dsh-request-retry

pachellber-marine/dsh-request-retry

Auto-retry DSH model requests on transient relay-gateway failures (5xx, no-channel, rate limits, stream truncation) with exponential backoff

Stars
1
Forks
0
Issues
0
更新
6 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:pachellber-marine/dsh-request-retry

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-request-retry

English | 中文

中文

DSH(DeepSeekRuntime)插件:模型请求遇到临时性上游故障时自动重试,指数退避,直到上游恢复——而不是直接报「本轮运行失败」打断你的会话。

定位:面向中转站 / one-api / newapi 等 OpenAI 兼容网关用户的可靠性层。这类网关的报错以临时性故障为主(无可用渠道、负载饱和、限流、流截断),且报错形态中英混杂——本插件内置了两套匹配词,开箱即用。

如果你在用中转站、公益网关或任何不稳定的三方通道,多半见过这些报错:

500 No available channel for model xxx under group auto
503 upstream-reset (circuit open, next probe +37s)
400 Unmarshal chat params failed ...

这些故障的共同特点是:过一会儿就好了。但 DSH 默认只重试有限的次数,之后整轮回合直接失败——已经生成的长回答作废,你得重新发消息、重新等模型把几千 token 再吐一遍。长会话、长任务里这种打断尤其伤。

本插件接管 agent/request-error 事件:命中匹配词的失败会按指数退避重发同一个请求(复用同一次渲染组装,不重复计费、不重复注入),直到上游恢复或超出总窗口。其他错误(鉴权失败、参数错误、用户取消)照常交还 DSH 默认处理——插件不越权。

默认匹配的故障(可自行扩展)

匹配词 典型场景
No available channel 网关无可用通道(500)
circuit open 上游熔断快速失败(503)
upstream-reset 上游连接被重置
ECONNRESET 网络层断连
fetch failed Node fetch 网络错误
Unmarshal chat params 网关解析请求体失败(400 bad_params,报错自带 RETRY 建议)
upstream_stream_truncated 流中途截断(HTTP 200 但未收到终止事件,报错 code)
stream ended before a completion event 同上,报错 message 形态
request_body_busy 网关大请求解码预算占用(503,等活跃请求结束后重试)
large decoded request budget is busy 同上,报错 message 形态
无可用渠道 中转站无可用渠道(临时性,渠道恢复后可重试)
当前分组 分组下暂无可用渠道/模型的常见措辞
负载已饱和 中转站负载饱和(临时性)
insufficient_quota 上游配额暂时耗尽(部分网关为临时态)
too many requests 限流(429 常见措辞)
rate limit 限流(英文通用措辞)
overloaded 上游过载(部分厂商 529/503 措辞)
渠道不存在 newapi 中文报错变体「分组 xx 下模型 yy 的可用渠道不存在(retry)」
channel:no_available_key newapi 内部 code:渠道密钥全部失败(临时性,等渠道恢复)
请稍后再试 newapi 临时性错误的通用标记(分组饱和等);确定性错误文案均不含此词

匹配同时查报错的 code 和 message(code message 拼接后做包含匹配),所以按 code 命中的错误(如 upstream_stream_truncated)不依赖 message 文本。

重试策略

  • 退避:首次 3 秒起,每轮 ×1.5,单次等待封顶 5 分钟
  • 报错带 retryAfterSeconds 时(熔断器探活节奏),至少等该秒数 + 2s 再重发——不在熔断期做无效请求
  • maxRetries: 0 = 无限重试;maxRetryMs: 28800000 = 总重试窗口 8 小时,超窗后放行报错
  • 用户主动取消(signal abort)立即停止重试,绝不覆盖取消

安装

github:pachellber-marine/dsh-request-retry

或在 DSH 插件管理器 / 插件市场里搜 dsh-request-retry。

配置

在 cordis.patch.yml 的 insert 条目里加 config 字段即可覆盖默认值:

- insert:
    - id: request-retry
      name: dsh-request-retry
      config:
        matchPatterns: ['No available channel']   # 只保留你需要的
        maxRetryMs: 0                             # 0 = 永不放弃

所有可调参数:enabled / matchPatterns / initialDelayMs / maxDelayMs / backoffMultiplier / maxRetries / maxRetryMs。

注意

  • 重试复用同一次渲染组装,不会重复计费 pre-step / 用户消息。
  • 确定性错误(如 400 参数固定损坏)也会重试——重发的是同一个请求。确定性损坏建议把对应词从 matchPatterns 里删掉,别让它烧满 8 小时窗口。

English

A DSH (DeepSeekRuntime) plugin that auto-retries model requests on transient upstream failures with exponential backoff, keeping the session alive until the upstream recovers — instead of failing the turn immediately.

Positioning: a reliability layer for users of OpenAI-compatible relays (one-api / newapi gateways). These gateways fail mostly with transient errors — no available channel, saturated load, rate limits, truncated streams — and their error messages come in both English and Chinese. This plugin ships match patterns for both, out of the box.

If you route your models through relay stations, community gateways, or any third-party upstream, you have probably seen errors like these:

500 No available channel for model xxx under group auto
503 upstream-reset (circuit open, next probe +37s)
400 Unmarshal chat params failed ...

They share one property: they go away on their own. DSH's default handling retries a limited number of times and then fails the whole turn — losing a long generated answer and forcing you to resend. This plugin takes over the agent/request-error event: matching failures are resent after a backoff delay (reusing the same render assembly — no duplicated billing or injection), until the upstream recovers or the total window is exhausted. Everything else (auth errors, bad params, user cancellation) is handed back to DSH's default handling.

Retry policy

  • Backoff: starts at 3s, ×1.5 per attempt, single wait capped at 5 minutes
  • If the error carries retryAfterSeconds (circuit-breaker probe interval), wait at least that long + 2s before resending
  • maxRetries: 0 = unlimited; maxRetryMs: 28800000 = 8-hour total retry window
  • User cancellation (signal abort) always stops the retry loop

Install

github:pachellber-marine/dsh-request-retry

Configuration

Add a config block to the insert entry in cordis.patch.yml to override defaults. Tunables: enabled, matchPatterns, initialDelayMs, maxDelayMs, backoffMultiplier, maxRetries, maxRetryMs.

License

MIT

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度高

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek。