From 40569113678856f321e5b5c3fb2743d00d31d331 Mon Sep 17 00:00:00 2001 From: zhb <50901800+zhbdesign@users.noreply.github.com> Date: Thu, 25 Jun 2026 10:18:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=8D=E5=8A=A1=E5=95=86?= =?UTF-8?q?=E5=B8=A6=E6=9C=89[1m]=EF=BC=8C=E8=BF=90=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E5=B8=A6[1m]=E5=AF=BC=E8=87=B4thinking=E5=92=8Ceffort?= =?UTF-8?q?=E4=B8=8D=E7=94=9F=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复服务商带有[1m],运行时不带[1m]导致thinking和effort不生效问题 --- src/utils/model/modelSupportOverrides.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/utils/model/modelSupportOverrides.ts b/src/utils/model/modelSupportOverrides.ts index 56cb2519..a0460ba7 100644 --- a/src/utils/model/modelSupportOverrides.ts +++ b/src/utils/model/modelSupportOverrides.ts @@ -23,6 +23,17 @@ const TIERS = [ }, ] as const +/** + * Strip [1m]/[2m] context-window suffixes so capability overrides match + * regardless of whether the runtime model name includes the suffix. + * The suffix is a client-side marker (never sent to the API) but the + * pinned env var may carry it, while the runtime model passed to + * modelSupportsThinking/modelSupportsEffort may not. + */ +function stripContextSuffix(model: string): string { + return model.replace(/\[(1|2)m\]/gi, '') +} + /** * Check whether a 3p model capability override is set for a model that matches one of * the pinned ANTHROPIC_DEFAULT_*_MODEL env vars. @@ -32,12 +43,12 @@ export const get3PModelCapabilityOverride = memoize( if (getAPIProvider() === 'firstParty' && isFirstPartyAnthropicBaseUrl()) { return undefined } - const m = model.toLowerCase() + const m = stripContextSuffix(model.toLowerCase()) for (const tier of TIERS) { const pinned = process.env[tier.modelEnvVar] const capabilities = process.env[tier.capabilitiesEnvVar] if (!pinned || capabilities === undefined) continue - if (m !== pinned.toLowerCase()) continue + if (m !== stripContextSuffix(pinned.toLowerCase())) continue return capabilities .toLowerCase() .split(',') @@ -46,5 +57,5 @@ export const get3PModelCapabilityOverride = memoize( } return undefined }, - (model, capability) => `${model.toLowerCase()}:${capability}`, + (model, capability) => `${stripContextSuffix(model.toLowerCase())}:${capability}`, )