dsh-reconnect:DSH 模型請求安全重試與網關恢復

前言

在 DeepSeek Harness(DSH)裏跑智能體或長任務時,模型請求常因短暫網絡抖動、網關異常或上游限流而失敗。若只依賴 Provider 內置的 normal 重試策略,策略耗盡後輪次往往直接中斷。下面介紹社區插件 dsh-reconnect(維護者 mrbeandev),它在 DSH 的 agent/request-error 瀑布流上接管可恢復錯誤,用指數退避重新提交同一模型請求,並支持 Web 端配置面板。

這是什麼

dsh-reconnect 是 DSH 的模型推理類插件,npm 包名 dsh-reconnect,當前版本 2.0.0(MIT 許可證)。定位是:在內置 Provider 重試用盡後,或由 always 策略把恢復交給下游時,對可恢復的模型請求做安全重試,避免臨時故障打斷 agent turn 或長任務。

插件監聽 DSH 的 agent/request-error 事件;依據機器可讀的錯誤碼決定是否重試,不會從任意 tool 輸出推斷模型失敗(tool/result 中的工具執行失敗不在本插件重試邊界內)。

重試策略

README 中的策略如下(與 Provider 策略配合使用):

條件 行爲
EMPTY_RESPONSE、RATE_LIMIT、SERVER、STREAM_CLOSED、TIMEOUT、TRANSPORT 無限重試
模型缺失或未配置 在配置恢復前無限重試
QUOTA 默認不重試;可通過 retryQuota 開啓
未知錯誤(如 PI_AI_ERROR) 默認無限重試;關閉 retryUnknown 後可設上限
工具、參數、認證、憑證、上下文溢出、中止類錯誤 不重試

退避、取消與會話事件

  • 指數退避:1s → 2s → 4s → …,默認上限 60 秒(由 maxDelayMs 控制本地退避上限,不限制 Provider 的 Retry-After 或總重試時長)。
  • 若 Provider 返回正的 Retry-After,會作爲無上限下限的最小等待時間。
  • 發出標準 llm/retry、llm/retry-started 會話事件;Harness 對話 UI 可顯示重試次數與倒計時。
  • turn 中止或插件卸載時立即停止;熱重載與關閉時會安全排空 pending 等待。

安裝與啓用

推薦通過 npm 在 web profile 安裝並激活:

dsh plugin --profile web add dsh-reconnect

安裝後需重啓正在運行的 DSH web 進程。包聲明瞭 dsh.bundle patch,profile 包管理器會自動加入 active bundle,一般無需手改 cordis.yml。

更新或移除:

dsh plugin --profile web update dsh-reconnect
dsh plugin --profile web remove dsh-reconnect

也可從 GitHub 安裝,並可釘住版本以便復現:

dsh plugin --profile web add github:mrbeandev/dsh-reconnect
dsh plugin --profile web add github:mrbeandev/dsh-reconnect#v2.0.0

環境要求(來自 README):

  • 帶 Host settings 服務的 DeepSeek Harness
  • Node.js ^22.19.0 或 >=24.0.0
  • 使用 web profile 才能看到可視化設置卡片(客戶端設置卡片不讀取憑證)

配置與設置面板

在 Settings → Plugins → Plugin configuration → ReConnect automatic retry 中可調整:

  • Maximum retry delay:1、2、5、10、30、60、120 秒或自定義值
  • Retry quota errors:默認關閉
  • Retry unknown errors indefinitely:默認開啓
  • Maximum unknown-error retries:默認 3,僅在關閉無限未知錯誤重試時生效

修改後立即生效。

YAML 示例(插入 reconnect 插件塊):

- insert:
    - id: reconnect
      name: dsh-reconnect
      config:
        maxDelayMs: 15000
        retryQuota: false
        retryUnknown: true
        unknownMaxRetries: 3
配置項 類型 默認 說明
maxDelayMs integer 60000 本地指數退避最大延遲(毫秒)
retryQuota boolean false 是否對配額/餘額耗盡類錯誤無限重試
retryUnknown boolean true 是否對未知錯誤碼無限重試
unknownMaxRetries integer 3 retryUnknown 爲 false 時,連續未知錯誤上限

適用場景與注意

適合:需要長時間跑 agent、對網關/網絡/限流偶發失敗容忍度要求高、希望在 UI 裏看清重試進度的 DSH web 用戶。

注意:

  1. 插件在當前 DSH 進程權限下運行;安裝前請自行審閱 GitHub 源碼 與 MIT 許可證。
  2. 配額類錯誤默認不重試,避免在餘額耗盡時無意義刷請求;若業務明確需要,再開啓 retryQuota。
  3. 社區插件目錄 SkillHub 爲獨立生態站點,與 DeepSeek / 幻方無官方從屬關係;DSH 本身遵循「一切皆插件」,本包爲 npm 與 GitHub 上的社區維護版本,英文版基於 MIT 授權的 MistRain-1/dsh-reconnect 演進。

結尾

經過上面的步驟,你可以在 Provider 重試之外多一層可配置、可觀測的模型請求恢復能力。目錄頁:https://www.skillhub.cn/plugins/mrbeandev/dsh-reconnect;源碼與完整說明:https://github.com/mrbeandev/dsh-reconnect;npm:https://www.npmjs.com/package/dsh-reconnect。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜