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'));