fix(shared): restrict cached Anthropic 1M context to GA 4.6 models only
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import process from "node:process"
|
||||
|
||||
const DEFAULT_ANTHROPIC_ACTUAL_LIMIT = 200_000
|
||||
const ANTHROPIC_NO_HEADER_GA_MODEL_IDS = new Set([
|
||||
"claude-opus-4-6",
|
||||
"claude-opus-4.6",
|
||||
"claude-sonnet-4-6",
|
||||
"claude-sonnet-4.6",
|
||||
])
|
||||
|
||||
export type ContextLimitModelCacheState = {
|
||||
anthropicContext1MEnabled: boolean
|
||||
@@ -20,6 +26,10 @@ function getAnthropicActualLimit(modelCacheState?: ContextLimitModelCacheState):
|
||||
: DEFAULT_ANTHROPIC_ACTUAL_LIMIT
|
||||
}
|
||||
|
||||
function isAnthropicNoHeaderGaModel(modelID: string): boolean {
|
||||
return ANTHROPIC_NO_HEADER_GA_MODEL_IDS.has(modelID.toLowerCase())
|
||||
}
|
||||
|
||||
export function resolveActualContextLimit(
|
||||
providerID: string,
|
||||
modelID: string,
|
||||
@@ -30,7 +40,7 @@ export function resolveActualContextLimit(
|
||||
if (explicit1M === 1_000_000) return explicit1M
|
||||
|
||||
const cachedLimit = modelCacheState?.modelContextLimitsCache?.get(`${providerID}/${modelID}`)
|
||||
if (cachedLimit) return cachedLimit
|
||||
if (cachedLimit && isAnthropicNoHeaderGaModel(modelID)) return cachedLimit
|
||||
|
||||
return DEFAULT_ANTHROPIC_ACTUAL_LIMIT
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user