dsh-auto-review-model-router:把 auto-review 審閱請求路由到指定模型

前言

在 DeepSeek Harness(DSH)裏,若啓用了實驗性的 @deepseek-ai/dsh-experimental-auto-review,每次需要安全門控的工具調用都會額外走一遍 LLM 審閱。審閱實現會從當前會話的請求頭裏複製 provider 和 model,也就是說審閱和主智能體共用同一條模型路由。主會話若選的是 Claude Opus、GPT 等高單價模型,每一次 gated 調用都會多計一次同檔模型的完整請求,成本會疊在 agent 本身之上。

社區插件 dsh-auto-review-model-router 只做一件事:識別 auto-review 發出的審閱請求,把其路由改到你配置的 reviewModel,主會話的 agent 模型不變。下面介紹它的定位、安裝方式與配置項,均依據倉庫 README 與 package 信息。

這是什麼

dsh-auto-review-model-router 是 OldLigant 維護的 DSH 插件,npm 包名同爲 dsh-auto-review-model-router,當前版本 0.2.1,許可證 MIT。分類上屬於模型推理相關能力:不改變審閱提示詞、策略 system prompt、溫度或 gate 解析的 {"risk":…,"decision":…} JSON 協議,只替換產出 verdict 的模型。

若你使用的是獨立插件 dsh-auto-review,其自帶 reviewerModel 配置,無需本插件。本插件針對的是 experimental auto-review bundle 沒有 reviewModel 字段、審閱被迫走會話路由的情況。

核心功能

問題與行爲

@deepseek-ai/dsh-experimental-auto-review 通過 ctx.llm.stream() 審閱,路由來自會話 snapshot(README 指向 snapshotAutoReview())。本插件在激活時包裝 LlmRuntime 上的 llm.stream(以及默認開啓的 llm.prepareCall),僅對「手工構建、且 system 以 auto-review 固定 REVIEW_POLICY 開頭」的請求改道。

改道時會複製到 reviewModel,並默認丟棄源路由上的 reasoningEffort 與 maxTokens,避免目標模型不支持 reasoning effort 或輸出上限更小導致審閱全部失敗。審閱內容與其餘參數保持原樣。

transient 失敗重試

gate 在 agent loop 外直接調用 llm.stream, harness 的 agent 側重試插件看不到審閱失敗。本插件對單次審閱在 transient 錯誤上自行重試(默認 retryAttempts 爲 4,即最多 5 次嘗試),僅重試 harness 視爲 transient 的碼:EMPTY_RESPONSE、RATE_LIMIT、SERVER、TRANSPORT; deliberately 不重試 TIMEOUT(DeepSeek 適配器 idle watchdog)、ABORTED 與 AUTH 等。

實現取捨(閱讀 README 時的要點)

README 說明曾嘗試 llm/stream listener 或直接寫 ctx.llm.stream,在真實 runtime 上不可行(請求被 deepFreeze、Cordis waterfall 語義、traceable proxy 等)。因此插件在擁有方法的 prototype(實踐中爲 LlmRuntime.prototype)上安裝 wrapper,並在 fiber dispose 時移除。prepareCall 路徑需在 prepare 階段改路由,否則會出現 INVALID_PREPARED_CALL。

安裝與啓用

在 profile 目錄 安裝 npm 包(勿用未在文檔出現的 dsh plugin add github:… 拼接命令):

# in the profile directory
pnpm add dsh-auto-review-model-router

本地 checkout 時可在 profile 的 package.json 裏 link:

// <profile>/package.json
"dependencies": { "dsh-auto-review-model-router": "link:D:/path/to/dsh-auto-review-model-router" }

在 profile 的 patch 層插入插件條目,README 要求放在 auto-review bundle 之後:

# <profile>/cordis.patch.yml
- insert:
    - id: auto-review-model-router
      name: dsh-auto-review-model-router
      config:
        reviewModel: deepseek-official/deepseek-flash

修改 patch 層後需重啓應用;變更在 profile 啓動時生效。運行環境要求 Node ^22.19.0 || >=24.0.0(見 package.json engines)。

典型用法與配置

最小配置即指定審閱模型,格式爲 <provider>/<model>,例如 README 示例中的 deepseek-official/deepseek-flash。配置後,審閱走該路由,agent 仍可保持 claude-opus-4、gpt-6-astra 等會話所選模型。

完整配置字段如下(默認值以 README 表格爲準):

字段 默認 含義
reviewModel deepseek-official/deepseek-flash 每次審閱使用的 provider/model;空字符串關閉路由
systemPromptPatterns 內置 REVIEW_POLICY 開頭 匹配 system 的子串或 /regex/u,僅在 harness 改寫審閱 prompt 時需放寬
retryAttempts 4 首次失敗後的重試次數,最多 10;0 關閉
retryDelayMs 500 重試前等待毫秒
wrapPrepareCall true 是否同樣路由經 llm.prepareCall 發出的審閱
dropReasoningEffort true 審閱請求上丟棄源路由 reasoning effort
dropMaxTokens true 審閱請求上丟棄源路由 max tokens
logRetargets true 是否記錄每次改道;重試總會打 warning

運行時改道與重試日誌示例(README):

auto-review-model-router: review request re-routed anthropic/claude-opus-4 -> deepseek-official/deepseek-flash (stream)
auto-review-model-router: review attempt 1/5 failed with TRANSPORT; retrying in 500 ms

倉庫測試:node test/router.test.js;在能解析 @deepseek-ai/dsh-llm 的環境下 DSH_PROFILE_DIR=<profile dir> node test/live.test.js。

適用場景與注意

適合誰: 已在 profile 中啓用 @deepseek-ai/dsh-experimental-auto-review,希望審閱固定走便宜或專用 flash 模型,又不想改 agent 主路由的 DSH 用戶。

範圍與風險: 僅被識別爲 auto-review 的請求會改路由;誤識別爲 false negative 時行爲與未裝插件相同。DSH 公開 API 仍屬 pre-stable;若 REVIEW_POLICY 開頭、LlmRuntime.prototype 方法名或 prepared-handle 契約變化,可能需要升級插件或通過 systemPromptPatterns 調整檢測。缺少所需方法時插件會 warning 而非阻止 profile 啓動。

安全與信任: 插件以當前 DSH 進程權限運行,會 patch LlmRuntime.prototype 並攔截 LLM 流式調用。安裝前請閱讀 GitHub 倉庫 源碼與 MIT 許可證,自行判斷是否納入 profile。

DSH 生態強調「一切皆插件」;SkillHub 目錄頁 爲社區站點,與 DeepSeek / 幻方無官方從屬關係。

結尾

dsh-auto-review-model-router 把 experimental auto-review 的審閱流量從會話高價模型上拆開,用配置項 reviewModel 和可選重試降低 gated 工具調用的審閱成本,同時保持 agent 路由不變。需要細節與更新時以 GitHub README 爲準:

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

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

小夜