Back to home@haochi72

dsh-auto-continue-429

No description

Stars
0
Language
JavaScript
Created
Aug 18, 2026
Updated
Aug 18, 2026
GitHub repo

Introduction

dsh-auto-continue-429

DeepSeek Harness(DSH)插件:遇到 429 限流 / 配额耗尽自动 continue 恢复对话,20 次连续失败才停,成功一次即清零。


✨ 功能特色

能力说明
🔄 自动 Continuedsh-llm-retry 的 step 级重试耗尽后,自动发送 continue 开启新 turn
🚦 识别 429 与配额耗尽监听 RATE_LIMIT(429)与 QUOTAinsufficient_quota 等)两类错误码
🎛 对话框底部开关输入区底部「开/关」滑动开关,点击即切换,无需去设置页
⚙ 设置页主开关「启用插件」主开关:停用后插件整体失效,对话框不再显示开关按钮(两开关互不联动)
🧮 连续失败计数连续失败 20 次才停止,任何一次 turn 正常结束即清零
⏱️ 固定 2 秒退避每次 429 后等待 2 秒发送 continue(API Retry-After 更短则优先)
📱 计数徽章开关条上显示 5/20 样式,橙色=已发生重试,深色=干净
💾 设置持久化开关状态/隐藏状态保存在 ~/.dsh/auto-continue-429.json

UI 交互示例:

┌─────────────────────────────────────────┐
│                                         │
│   对话内容                               │
│                                         │
│  [🟢429] [开]      ← 对话框底部开关条    │
│  (设置页停用插件后,此开关条自动隐藏)     │
└─────────────────────────────────────────┘

📦 安装

方式 1:已发布到 npm(发布后)

cd ~/.dsh/profiles/web
pnpm add dsh-auto-continue-429

方式 2:从 GitHub 安装

dsh plugin --profile web add github:haochi72/dsh-auto-continue-429

方式 3:本地开发链接

cd ~/.dsh/profiles/web
pnpm link /path/to/dsh-auto-continue-429

然后在 ~/.dsh/profiles/web/package.jsondsh.profile.bundles 数组末尾加上:

"dsh-auto-continue-429"

重启 DSH Desktop 生效。


🚀 使用

1. 确认加载成功

重启 DSH 后在对话框输入区底部,应该出现一个胶囊形的 「429」开关条(绿色=已开启)。

2. 控制开关

操作效果
点击对话框底部的开关条切换快捷开关quickOn),绿色=开,灰色=关
设置页 → 429 自动 Continue 卡片 →「启用插件」切换主开关enabled),与对话框快捷开关互不联动
在设置页停用插件对话框底部的开关条自动隐藏;重新启用后恢复显示
设置页 →「连续失败上限」自定义失败多少轮后停止自动 continue(1-100)

3. 遇到 429 / 配额耗尽时的行为

LLM 返回 429 或配额耗尽(insufficient_quota)
  ↓
dsh-llm-retry 在当前 step 内重试 2 次(内置)
  ↓
重试耗尽 → turn 以 error(RATE_LIMIT / QUOTA) 结束
  ↓
★ 本插件介入
  ↓
等 2 秒 → 发送 "continue" → 新 turn 启动 ✅
  ↓
(如果又 429)
  ↓
等 2 秒 → 发送 "continue" → …(重复到第 20 次)
  ↓
如果某次 turn 正常结束(reason.kind ≠ error)→ 计数归零 🎉
  ↓
连续 20 次全失败 → 停止,等待手动介入

⚙️ 配置(可选)

插件提供以下 Schema 配置项(在 cordis.patch.yml 或 profile 配置中声明):

- id: auto-continue-429
  name: dsh-auto-continue-429
  config:
    maxRetries: 20          # 连续失败最大次数(默认20)
    initialDelayMs: 2000    # 每次失败后的等待时间(毫秒,默认2000=2秒)
    maxDelayMs: 60000       # API Retry-After 上限(毫秒)
    jitterRatio: 0.15       # 抖动比例(保留用于将来扩展,当前未使用)
    continueMessage: "continue"  # 发送的 continue 消息文本

🧩 架构

本插件是 DSH 标准的双端插件(Cordis 驱动):

dsh-auto-continue-429/
├── package.json          # dsh.bundle.patch 声明 + dsh.client 声明
├── cordis.patch.yml      # bundle 层补丁:插入插件行
├── lib/
│   ├── index.js          # 宿主端:错误拦截 + 退避 + continue + HTTP 路由
│   └── client.js         # 客户端:对话框底部开关条 + 设置页卡片
├── LICENSE               # MIT
└── README.md

宿主端接入点

接入点说明
ctx.inject(["webServer"])注册 5 个 HTTP 路由供客户端轮询与控制
ctx.on("session/event", …)监听 turn/end,检测 RATE_LIMIT / QUOTA 错误码后调度 continue(全局监听,覆盖所有会话)
ctx.agents.get(sessionId).followup(…)发送 continue 用户消息

客户端接入点

纯 DOM 注入(不依赖 React),通过 HTTP fetch 与宿主端通信:

  • 启动时在对话框输入区底部创建「开/关」开关条
  • 每 2 秒 GET /api/auto-continue-429/state 同步状态
  • POST /toggle-quick 切换对话框快捷开关、POST /toggle 切换设置页主开关、POST /set-max-retries 保存失败上限
  • MutationObserver 监听设置页 DOM 自动注入设置卡片;输入区被 SPA 重渲染时自动重新挂载开关条

🔒 权限

  • 不访问文件系统:仅 ~/.dsh/auto-continue-429.json 保存开关状态(<1KB)
  • 不读取 API Key:完全复用 DSH 内置的 agent/followup 通道
  • 不外发任何网络请求:所有 HTTP 路由走 DSH 内置 webServer(localhost 回环)

🐛 调试

宿主端日志(DSH stdout):

[auto-continue-429] 会话 sess_xxx 连续失败第 3/20 次,2000ms 后自动 continue
[auto-continue-429] 已发送 continue 到会话 sess_xxx
[auto-continue-429] 已达连续失败上限 20 次,停止自动 continue

设置文件路径:

~/.dsh/auto-continue-429.json
→ {"enabled": true, "quickOn": true, "buttonHidden": false, "maxRetries": 20}

📜 开源协议

MIT © 2026