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
+30 -6
+30 -6
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,14 +76,10 @@ 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));
return;
}
Object.assign( Object.assign(
envVars, envVars,
applyExtendedContextPreferenceToAnthropicModels(envVars, true, { applyExtendedContextPreferenceToAnthropicModels(envVars, extendedContextOverride, {
supportsExtendedContext: (modelId) => supportsExtendedContext: (modelId) =>
shouldApplyExtendedContext( shouldApplyExtendedContext(
provider, provider,
@@ -89,4 +88,29 @@ export function applyExtendedContextConfig(
), ),
}) })
); );
return;
}
// Auto mode (no explicit --1m/--no-1m this launch): don't force-strip a
// previously saved [1m] preference just because the model is Claude — only
// strip when the model no longer supports extended context. Native Gemini
// models still get auto-toggled based on catalog support.
for (const key of ANTHROPIC_MODEL_ENV_KEYS) {
const value = envVars[key];
if (typeof value !== 'string' || value.trim().length === 0) {
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);
}
}
} }