修复第三方API在响应中返回的model与请求的modelid不一致导致上下文显示200000

修复第三方API在响应中返回的model与请求的modelid不一致导致上下文显示200000
This commit is contained in:
zhb 2026-06-23 20:03:58 +08:00 committed by GitHub
parent 192ed4bdce
commit 2e6caa358c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1390,10 +1390,11 @@ export class SessionService {
for (const providerId of providerIds) {
const env = await this.providerService.getProviderRuntimeEnv(providerId).catch(() => null)
const rawContextWindows = env?.[MODEL_CONTEXT_WINDOWS_ENV_KEY] ?? null
// Step 1: Try matching the transcript model name directly (current behavior)
const contextWindow = getModelContextWindowFromEnvValue(
model,
env?.[MODEL_CONTEXT_WINDOWS_ENV_KEY],
rawContextWindows,
)
if (contextWindow !== undefined) {
if (contextWindow > MODEL_CONTEXT_WINDOW_DEFAULT && is1mContextDisabled()) {
@ -1443,10 +1444,11 @@ export class SessionService {
for (const provider of providers) {
const env = await this.providerService.getProviderRuntimeEnv(provider.id).catch(() => null)
const rawContextWindows = env?.[MODEL_CONTEXT_WINDOWS_ENV_KEY] ?? null
// Step 1: Try matching the transcript model name directly
const contextWindow = getModelContextWindowFromEnvValue(
model,
env?.[MODEL_CONTEXT_WINDOWS_ENV_KEY],
rawContextWindows,
)
if (contextWindow !== undefined) {
matches.push(contextWindow)
@ -1463,12 +1465,6 @@ export class SessionService {
rawContextWindows,
)
if (fallbackWindow !== undefined) {
traceDebug('CTX_WIN', 'getUniqueSavedProviderContextWindow — fallback match via configured model', {
transcriptModel: model,
configuredModel,
envKey,
fallbackWindow,
})
matches.push(fallbackWindow)
break // One match per provider is enough
}