From a9c51021aa4fb39a364660e2dc61c330f4a59c9e Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Wed, 24 Jun 2026 23:44:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(models):=20isModelError=20=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E3=80=8Cissue=20with=20the=20selected=20model?= =?UTF-8?q?=E3=80=8D=E2=86=92=20=E8=A7=A6=E5=8F=91=E5=9B=9E=E9=80=80?= =?UTF-8?q?=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 线上实测:reviewer 用 fable-5 报「There's an issue with the selected model (claude-fable-5)」(该档未对当前账号开通),但 isModelError 未命中此措辞 → 不回退 → 复审失败(verdict=null)。补正则后 fable-5 不可用会自动回退 opus 重试,复审正常。 Co-Authored-By: Claude Opus 4.8 --- src/executor/models.ts | 6 ++++-- test/models.test.ts | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/executor/models.ts b/src/executor/models.ts index ffbfaef..a3dcf6b 100644 --- a/src/executor/models.ts +++ b/src/executor/models.ts @@ -71,10 +71,12 @@ export function pickClassifierModel(): string { return process.env[env]?.trim() || fallback; } -/** 错误信息是否像“模型不可用”(not_found / invalid / permission 等模式 + 提到 model) */ +/** 错误信息是否像“模型不可用”(not_found / invalid / permission 等模式 + 提到 model) + * 含 Claude Code 的「There's an issue with the selected model (X)」——某档模型未对当前账号开通时的报错, + * 必须命中才能触发回退链(如 fable-5 未开通 → 回退 opus)。 */ export function isModelError(msg: string): boolean { if (!/model/i.test(msg)) return false; - return /not[_\s-]?found|invalid|permission|forbidden|unauthorized|unavailable|unknown|unsupported|does not exist|no access|404|403/i.test(msg); + return /not[_\s-]?found|invalid|permission|forbidden|unauthorized|unavailable|unknown|unsupported|does not exist|no access|issue with (the )?selected model|404|403/i.test(msg); } /** 回退链里取失败模型的下一档(循环);未在链上则取首档。 */ diff --git a/test/models.test.ts b/test/models.test.ts index f33266b..c84195f 100644 --- a/test/models.test.ts +++ b/test/models.test.ts @@ -94,6 +94,8 @@ test('isModelError:模型不可用类错误才触发回退', () => { assert.ok(isModelError('404 model does not exist')); assert.ok(isModelError('The requested model is unavailable')); assert.ok(isModelError('unknown model "claude-fable-5"')); + // Claude Code 的「未开通某档模型」报错(线上 fable-5 实测) + assert.ok(isModelError("There's an issue with the selected model (claude-fable-5)")); // 不应触发 assert.ok(!isModelError('执行超时')); assert.ok(!isModelError('network connection refused'));