fix: prioritize configured context limit (#9263)

This commit is contained in:
Haoran Xu
2026-07-15 15:33:12 +08:00
committed by GitHub
parent 8f6a8fad24
commit 259ae3d2c8

View File

@@ -23,7 +23,7 @@ export function contextLimit(
provider: ProviderMetadataSource | null | undefined,
metadata?: ProviderModelMetadata | null
): number {
const context = Number(metadata?.limit?.context || provider?.max_context_tokens || 0)
const context = Number(provider?.max_context_tokens) || Number(metadata?.limit?.context) || 0
return Number.isFinite(context) && context > 0 ? context : 0
}