fix: 移除 auto mode 的 provider 和模型白名单限制

移除 firstParty provider 限制和 claude-(opus|sonnet)-4-[67] 模型白名单,
使所有模型和 provider 在 TRANSCRIPT_CLASSIFIER feature 启用时均可使用 auto mode。

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
This commit is contained in:
claude-code-best 2026-05-10 17:47:38 +08:00 committed by James Feng
parent d35f0db17d
commit 90406a10be

View File

@ -16,17 +16,20 @@ import {
REDACT_THINKING_BETA_HEADER, REDACT_THINKING_BETA_HEADER,
STRUCTURED_OUTPUTS_BETA_HEADER, STRUCTURED_OUTPUTS_BETA_HEADER,
TOKEN_EFFICIENT_TOOLS_BETA_HEADER, TOKEN_EFFICIENT_TOOLS_BETA_HEADER,
TOOL_SEARCH_BETA_HEADER_1P, SEARCH_EXTRA_TOOLS_BETA_HEADER_1P,
TOOL_SEARCH_BETA_HEADER_3P, SEARCH_EXTRA_TOOLS_BETA_HEADER_3P,
WEB_SEARCH_BETA_HEADER, WEB_SEARCH_BETA_HEADER,
} from '../constants/betas.js' } from '../constants/betas.js'
import { OAUTH_BETA_HEADER } from '../constants/oauth.js' import { OAUTH_BETA_HEADER } from '../constants/oauth.js'
import { isClaudeAISubscriber } from './auth.js' import { isClaudeAISubscriber } from './auth.js'
import { has1mContext } from './context.js' import { has1mContext } from './context.js'
import { isEnvDefinedFalsy, isEnvTruthy } from './envUtils.js' import { isEnvTruthy } from './envUtils.js'
import { getCanonicalName } from './model/model.js' import { getCanonicalName } from './model/model.js'
import { get3PModelCapabilityOverride } from './model/modelSupportOverrides.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' import { getInitialSettings } from './settings/settings.js'
/** /**
@ -68,7 +71,6 @@ export function filterAllowedSdkBetas(
} }
if (isClaudeAISubscriber()) { if (isClaudeAISubscriber()) {
// biome-ignore lint/suspicious/noConsole: intentional warning
console.warn( console.warn(
'Warning: Custom betas are only available for API key users. Ignoring provided betas.', '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) const { allowed, disallowed } = partitionBetasByAllowlist(sdkBetas)
for (const beta of disallowed) { for (const beta of disallowed) {
// biome-ignore lint/suspicious/noConsole: intentional warning
console.warn( console.warn(
`Warning: Beta header '${beta}' is not allowed. Only the following betas are supported: ${ALLOWED_SDK_BETAS.join(', ')}`, `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-1') ||
canonical.includes('claude-opus-4-5') || canonical.includes('claude-opus-4-5') ||
canonical.includes('claude-opus-4-6') || canonical.includes('claude-opus-4-6') ||
canonical.includes('claude-opus-4-7') ||
canonical.includes('claude-haiku-4-5') canonical.includes('claude-haiku-4-5')
) )
} }
export function modelSupportsAutoMode(_model: string): boolean { 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. * 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 * - 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() const provider = getAPIProvider()
if (provider === 'vertex' || provider === 'bedrock') { 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 { export function shouldIncludeFirstPartyOnlyBetas(): boolean {
return ( return (
(getAPIProvider() === 'firstParty' || getAPIProvider() === 'foundry') && (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) betaHeaders.push(REDACT_THINKING_BETA_HEADER)
} }
// Add context management beta for tool clearing (ant opt-in) or thinking preservation // Add context management beta for tool clearing or thinking preservation.
const antOptedIntoToolClearing = // Tool clearing is enabled by default for all users (upstream gates on ant);
isEnvTruthy(process.env.USE_API_CONTEXT_MANAGEMENT) && // thinking preservation activates when the model supports context management.
process.env.USER_TYPE === 'ant' const toolClearingOptIn =
isEnvTruthy(process.env.USE_API_CONTEXT_MANAGEMENT) ||
modelSupportsContextManagement(model)
const thinkingPreservationEnabled = modelSupportsContextManagement(model) const thinkingPreservationEnabled = modelSupportsContextManagement(model)
if ( if (
shouldIncludeFirstPartyOnlyBetas() && shouldIncludeFirstPartyOnlyBetas() &&
(antOptedIntoToolClearing || thinkingPreservationEnabled) (toolClearingOptIn || thinkingPreservationEnabled)
) { ) {
betaHeaders.push(CONTEXT_MANAGEMENT_BETA_HEADER) betaHeaders.push(CONTEXT_MANAGEMENT_BETA_HEADER)
} }