From eeefecb7c3304fbe2889673fc8a04282b994484f Mon Sep 17 00:00:00 2001 From: Roo Code Date: Wed, 26 Nov 2025 12:15:09 +0000 Subject: [PATCH] fix: handle Ollama model names case-insensitively - Store Ollama models with both original and lowercase keys in getOllamaModels - Update useSelectedModel hook to try case-insensitive lookup for Ollama - Update NativeOllamaHandler to handle case-insensitive model lookups - Fixes issue where models like "GPT-OSS:120B" were rejected due to case mismatch Fixes #9608 --- src/api/providers/fetchers/ollama.ts | 9 ++++++++- src/api/providers/native-ollama.ts | 9 ++++++++- webview-ui/src/components/ui/hooks/useSelectedModel.ts | 8 +++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/api/providers/fetchers/ollama.ts b/src/api/providers/fetchers/ollama.ts index 4bf43b6faf..0e36c6606e 100644 --- a/src/api/providers/fetchers/ollama.ts +++ b/src/api/providers/fetchers/ollama.ts @@ -89,7 +89,14 @@ export async function getOllamaModels( { headers }, ) .then((ollamaModelInfo) => { - models[ollamaModel.name] = parseOllamaModel(ollamaModelInfo.data) + const modelInfo = parseOllamaModel(ollamaModelInfo.data) + // Store with original name + models[ollamaModel.name] = modelInfo + // Also store with lowercase name for case-insensitive lookup + const lowerName = ollamaModel.name.toLowerCase() + if (lowerName !== ollamaModel.name) { + models[lowerName] = modelInfo + } }), ) } diff --git a/src/api/providers/native-ollama.ts b/src/api/providers/native-ollama.ts index 83a5c7b36e..af1ba50f24 100644 --- a/src/api/providers/native-ollama.ts +++ b/src/api/providers/native-ollama.ts @@ -274,9 +274,16 @@ export class NativeOllamaHandler extends BaseProvider implements SingleCompletio override getModel(): { id: string; info: ModelInfo } { const modelId = this.options.ollamaModelId || "" + // Try exact match first, then lowercase for case-insensitive lookup + let modelInfo = this.models[modelId] + if (!modelInfo && modelId) { + // Try case-insensitive lookup + const lowerModelId = modelId.toLowerCase() + modelInfo = this.models[lowerModelId] + } return { id: modelId, - info: this.models[modelId] || openAiModelInfoSaneDefaults, + info: modelInfo || openAiModelInfoSaneDefaults, } } diff --git a/webview-ui/src/components/ui/hooks/useSelectedModel.ts b/webview-ui/src/components/ui/hooks/useSelectedModel.ts index 3df7236713..24f23eece9 100644 --- a/webview-ui/src/components/ui/hooks/useSelectedModel.ts +++ b/webview-ui/src/components/ui/hooks/useSelectedModel.ts @@ -281,7 +281,13 @@ function getSelectedModel({ } case "ollama": { const id = apiConfiguration.ollamaModelId ?? "" - const info = ollamaModels && ollamaModels[apiConfiguration.ollamaModelId!] + // Try exact match first, then lowercase for case-insensitive lookup + let info = ollamaModels && ollamaModels[apiConfiguration.ollamaModelId!] + if (!info && ollamaModels && apiConfiguration.ollamaModelId) { + // Try case-insensitive lookup + const lowerModelId = apiConfiguration.ollamaModelId.toLowerCase() + info = ollamaModels[lowerModelId] + } const adjustedInfo = info?.contextWindow &&