fix: claude model no get the 1m tag

This commit is contained in:
Kenneth Wong committed 2026-07-10 00:39:19 +08:00
1 parent da6c99e3df
commit 7f369f75dc
1 file changed
+37 -13
+37 -13
View File
@@ -13,9 +13,12 @@ import type { CLIProxyProvider } from '../types';
import { supportsExtendedContext } from '../model-catalog'; import { supportsExtendedContext } from '../model-catalog';
import { warn } from '../../utils/ui'; import { warn } from '../../utils/ui';
import { import {
ANTHROPIC_MODEL_ENV_KEYS,
applyExtendedContextPreferenceToAnthropicModels, applyExtendedContextPreferenceToAnthropicModels,
applyExtendedContextSuffix as applyExtendedContextSuffixShared, applyExtendedContextSuffix as applyExtendedContextSuffixShared,
hasExtendedContextSuffix,
isNativeGeminiModel, isNativeGeminiModel,
stripExtendedContextSuffix,
stripModelConfigurationSuffixes, stripModelConfigurationSuffixes,
} from '../../shared/extended-context-utils'; } from '../../shared/extended-context-utils';
@@ -73,20 +76,41 @@ export function applyExtendedContextConfig(
provider: CLIProxyProvider, provider: CLIProxyProvider,
extendedContextOverride?: boolean extendedContextOverride?: boolean
): void { ): void {
if (extendedContextOverride === false) { if (extendedContextOverride === true || extendedContextOverride === false) {
Object.assign(envVars, applyExtendedContextPreferenceToAnthropicModels(envVars, false)); Object.assign(
envVars,
applyExtendedContextPreferenceToAnthropicModels(envVars, extendedContextOverride, {
supportsExtendedContext: (modelId) =>
shouldApplyExtendedContext(
provider,
stripModelConfigurationSuffixes(modelId),
extendedContextOverride
),
})
);
return; return;
} }
Object.assign( // Auto mode (no explicit --1m/--no-1m this launch): don't force-strip a
envVars, // previously saved [1m] preference just because the model is Claude — only
applyExtendedContextPreferenceToAnthropicModels(envVars, true, { // strip when the model no longer supports extended context. Native Gemini
supportsExtendedContext: (modelId) => // models still get auto-toggled based on catalog support.
shouldApplyExtendedContext( for (const key of ANTHROPIC_MODEL_ENV_KEYS) {
provider, const value = envVars[key];
stripModelConfigurationSuffixes(modelId), if (typeof value !== 'string' || value.trim().length === 0) {
extendedContextOverride continue;
), }
}) const modelId = stripModelConfigurationSuffixes(value);
);
if (isNativeGeminiModel(modelId)) {
envVars[key] = supportsExtendedContext(provider, modelId)
? applyExtendedContextSuffixShared(value)
: value;
continue;
}
if (hasExtendedContextSuffix(value) && !supportsExtendedContext(provider, modelId)) {
envVars[key] = stripExtendedContextSuffix(value);
}
}
} }