From 90406a10be1d57a6ccf8add4fbff13ceae81382f Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Sun, 10 May 2026 17:47:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=20auto=20mode=20?= =?UTF-8?q?=E7=9A=84=20provider=20=E5=92=8C=E6=A8=A1=E5=9E=8B=E7=99=BD?= =?UTF-8?q?=E5=90=8D=E5=8D=95=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除 firstParty provider 限制和 claude-(opus|sonnet)-4-[67] 模型白名单, 使所有模型和 provider 在 TRANSCRIPT_CLASSIFIER feature 启用时均可使用 auto mode。 Co-Authored-By: glm-5-turbo --- src/utils/betas.ts | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/utils/betas.ts b/src/utils/betas.ts index 0611d0c87..87e24bf6a 100644 --- a/src/utils/betas.ts +++ b/src/utils/betas.ts @@ -16,17 +16,20 @@ import { REDACT_THINKING_BETA_HEADER, STRUCTURED_OUTPUTS_BETA_HEADER, TOKEN_EFFICIENT_TOOLS_BETA_HEADER, - TOOL_SEARCH_BETA_HEADER_1P, - TOOL_SEARCH_BETA_HEADER_3P, + SEARCH_EXTRA_TOOLS_BETA_HEADER_1P, + SEARCH_EXTRA_TOOLS_BETA_HEADER_3P, WEB_SEARCH_BETA_HEADER, } from '../constants/betas.js' import { OAUTH_BETA_HEADER } from '../constants/oauth.js' import { isClaudeAISubscriber } from './auth.js' import { has1mContext } from './context.js' -import { isEnvDefinedFalsy, isEnvTruthy } from './envUtils.js' +import { isEnvTruthy } from './envUtils.js' import { getCanonicalName } from './model/model.js' import { get3PModelCapabilityOverride } from './model/modelSupportOverrides.js' -import { getAPIProvider } from './model/providers.js' +import { + getAPIProvider, + isFirstPartyAnthropicBaseUrl, +} from './model/providers.js' import { getInitialSettings } from './settings/settings.js' /** @@ -68,7 +71,6 @@ export function filterAllowedSdkBetas( } if (isClaudeAISubscriber()) { - // biome-ignore lint/suspicious/noConsole: intentional warning console.warn( 'Warning: Custom betas are only available for API key users. Ignoring provided betas.', ) @@ -77,7 +79,6 @@ export function filterAllowedSdkBetas( const { allowed, disallowed } = partitionBetasByAllowlist(sdkBetas) for (const beta of disallowed) { - // biome-ignore lint/suspicious/noConsole: intentional warning console.warn( `Warning: Beta header '${beta}' is not allowed. Only the following betas are supported: ${ALLOWED_SDK_BETAS.join(', ')}`, ) @@ -151,25 +152,26 @@ export function modelSupportsStructuredOutputs(model: string): boolean { canonical.includes('claude-opus-4-1') || canonical.includes('claude-opus-4-5') || canonical.includes('claude-opus-4-6') || + canonical.includes('claude-opus-4-7') || canonical.includes('claude-haiku-4-5') ) } export function modelSupportsAutoMode(_model: string): boolean { - return feature('TRANSCRIPT_CLASSIFIER') ? true : false + return feature('TRANSCRIPT_CLASSIFIER') } /** * Get the correct tool search beta header for the current API provider. - * - Claude API / Foundry: advanced-tool-use-2025-11-20 * - Vertex AI / Bedrock: tool-search-tool-2025-10-19 + * - All other providers: advanced-tool-use-2025-11-20 */ -export function getToolSearchBetaHeader(): string { +export function getSearchExtraToolsBetaHeader(): string { const provider = getAPIProvider() if (provider === 'vertex' || provider === 'bedrock') { - return TOOL_SEARCH_BETA_HEADER_3P + return SEARCH_EXTRA_TOOLS_BETA_HEADER_3P } - return TOOL_SEARCH_BETA_HEADER_1P + return SEARCH_EXTRA_TOOLS_BETA_HEADER_1P } /** @@ -180,7 +182,8 @@ export function getToolSearchBetaHeader(): string { export function shouldIncludeFirstPartyOnlyBetas(): boolean { return ( (getAPIProvider() === 'firstParty' || getAPIProvider() === 'foundry') && - !isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS) + !isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS) && + isFirstPartyAnthropicBaseUrl() ) } @@ -241,16 +244,18 @@ export const getAllModelBetas = memoize((model: string): string[] => { betaHeaders.push(REDACT_THINKING_BETA_HEADER) } - // Add context management beta for tool clearing (ant opt-in) or thinking preservation - const antOptedIntoToolClearing = - isEnvTruthy(process.env.USE_API_CONTEXT_MANAGEMENT) && - process.env.USER_TYPE === 'ant' + // Add context management beta for tool clearing or thinking preservation. + // Tool clearing is enabled by default for all users (upstream gates on ant); + // thinking preservation activates when the model supports context management. + const toolClearingOptIn = + isEnvTruthy(process.env.USE_API_CONTEXT_MANAGEMENT) || + modelSupportsContextManagement(model) const thinkingPreservationEnabled = modelSupportsContextManagement(model) if ( shouldIncludeFirstPartyOnlyBetas() && - (antOptedIntoToolClearing || thinkingPreservationEnabled) + (toolClearingOptIn || thinkingPreservationEnabled) ) { betaHeaders.push(CONTEXT_MANAGEMENT_BETA_HEADER) }