fix: prioritize Anthropic 1M limits over cached context limits

This commit is contained in:
YeonGyu-Kim
2026-03-11 20:38:44 +09:00
parent bed1118636
commit 87ff1effdf
4 changed files with 84 additions and 11 deletions
+6 -5
View File
@@ -148,17 +148,18 @@ export async function getContextWindowUsage(
const lastTokens = lastAssistant?.tokens;
if (!lastAssistant || !lastTokens) return null;
const cachedLimit =
lastAssistant.providerID !== undefined && lastAssistant.modelID !== undefined
const modelSpecificLimit =
lastAssistant.providerID !== undefined &&
lastAssistant.modelID !== undefined &&
!isAnthropicProvider(lastAssistant.providerID)
? modelCacheState?.modelContextLimitsCache?.get(
`${lastAssistant.providerID}/${lastAssistant.modelID}`,
)
: undefined;
const actualLimit =
cachedLimit ??
(lastAssistant.providerID !== undefined && isAnthropicProvider(lastAssistant.providerID)
lastAssistant.providerID !== undefined && isAnthropicProvider(lastAssistant.providerID)
? getAnthropicActualLimit(modelCacheState)
: null);
: modelSpecificLimit ?? null;
if (!actualLimit) return null;