From f4500682cafc472bb52b3ffecab6f6dad85390ad Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Mon, 19 Oct 2026 18:14:20 +0000 Subject: [PATCH] fix(vscode): describe pinned Ollama models accurately on the Local Models page --- .../src/core/controller/models/loadOllamaModel.ts | 2 +- .../settings/sections/LocalModelsSection.tsx | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/vscode/src/core/controller/models/loadOllamaModel.ts b/apps/vscode/src/core/controller/models/loadOllamaModel.ts index 8becac7b13..37d89fb45f 100644 --- a/apps/vscode/src/core/controller/models/loadOllamaModel.ts +++ b/apps/vscode/src/core/controller/models/loadOllamaModel.ts @@ -12,7 +12,7 @@ export async function loadOllamaModel(_controller: Controller, request: OllamaMo await createOllamaClient(request.baseUrl).generate({ model: request.model, prompt: "", - // Stay loaded until explicitly unloaded. Cline's own requests reset this to the server's keep-alive. + // Stay loaded until explicitly unloaded; requests without a keep_alive don't shorten it. keep_alive: -1, ...(request.contextWindow ? { options: { num_ctx: request.contextWindow } } : {}), }) diff --git a/apps/vscode/webview-ui/src/components/settings/sections/LocalModelsSection.tsx b/apps/vscode/webview-ui/src/components/settings/sections/LocalModelsSection.tsx index 5eb4e17905..f0186632f3 100644 --- a/apps/vscode/webview-ui/src/components/settings/sections/LocalModelsSection.tsx +++ b/apps/vscode/webview-ui/src/components/settings/sections/LocalModelsSection.tsx @@ -73,7 +73,9 @@ function describeRunning(running: OllamaRunningModel): string { } // Ollama reports models pinned with keep_alive -1 as expiring centuries from now. const oneYearMs = 365 * 24 * 60 * 60 * 1000 - if (running.expiresAtMs > 0 && running.expiresAtMs - Date.now() < oneYearMs) { + if (running.expiresAtMs - Date.now() >= oneYearMs) { + parts.push("stays loaded until unloaded") + } else if (running.expiresAtMs > 0) { const time = new Date(running.expiresAtMs).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) parts.push(`unloads at ${time} if idle`) } @@ -442,10 +444,9 @@ const LocalModelsSection = ({ renderSectionHeader }: LocalModelsSectionProps) => )}

- Ollama unloads a model after a few minutes without requests to free up memory, so the next message may take a - moment while it loads again. Set the OLLAMA_KEEP_ALIVE environment variable for the Ollama server - to keep models loaded longer. The context window and server URL can be adjusted under API Configuration → - Ollama. + Models loaded here stay in memory until you unload them. A model Ollama loads on its own, when a message + arrives for it, is unloaded after a few minutes idle (configurable with OLLAMA_KEEP_ALIVE). The + context window and server URL can be adjusted under API Configuration → Ollama.