fix: cache context window from models.list, use for byok (#364)

This commit is contained in:
Ari Webb
2025-12-23 11:35:05 -08:00
committed by GitHub
parent ca5ff004e5
commit db517cff0e
2 changed files with 26 additions and 1 deletions

View File

@@ -3972,11 +3972,20 @@ DO NOT respond to these messages or otherwise consider them in your response unl
// If not found in static list, it might be a BYOK model where id === handle
if (!selectedModel && modelId.includes("/")) {
// Treat it as a BYOK model - the modelId is actually the handle
// Look up the context window from the API-cached model info
const { getModelContextWindow } = await import(
"../agent/available-models"
);
const apiContextWindow = getModelContextWindow(modelId);
selectedModel = {
id: modelId,
handle: modelId,
label: modelId.split("/").pop() ?? modelId,
description: "Custom model",
updateArgs: apiContextWindow
? { context_window: apiContextWindow }
: undefined,
} as unknown as (typeof models)[number];
}