mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: preserve selected OpenRouter models not in cache
When the OpenRouter model cache refreshes, preserve the user's currently selected model even if it's not in the API response. This prevents newer models (gpt-5.1, gemini-3, grok-4.1-fast, etc.) from being marked as invalid and automatically switching to Claude Sonnet. The fix adds the selected model to the models list with default values if it's missing, allowing continued use of models that aren't yet in the OpenRouter API response. Fixes #9597
This commit is contained in:
parent
099ea6dc6a
commit
1ee3ecb528
1 changed files with 17 additions and 0 deletions
|
|
@ -912,6 +912,23 @@ export const webviewMessageHandler = async (
|
|||
if (result.status === "fulfilled") {
|
||||
routerModels[routerName] = result.value.models
|
||||
|
||||
// For OpenRouter: preserve the currently selected model if it's not in the cache
|
||||
// This prevents newer models from being marked as invalid after cache refresh
|
||||
if (routerName === "openrouter" && apiConfiguration.openRouterModelId) {
|
||||
const selectedModelId = apiConfiguration.openRouterModelId
|
||||
// Only add if not already in the models list
|
||||
if (!routerModels[routerName][selectedModelId]) {
|
||||
// Create a minimal model info for the selected model
|
||||
// This allows users to continue using newer models that aren't in the API response yet
|
||||
routerModels[routerName][selectedModelId] = {
|
||||
maxTokens: 128000, // Default max tokens
|
||||
contextWindow: 128000, // Default context window
|
||||
supportsPromptCache: false,
|
||||
description: `Model ${selectedModelId} (preserved from configuration)`,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ollama and LM Studio settings pages still need these events. They are not fetched here.
|
||||
} else {
|
||||
// Handle rejection: Post a specific error message for this provider.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue