From 954ac0f3cac79178e76d498a7a1456b25df48aeb Mon Sep 17 00:00:00 2001 From: Teslim Olunlade <10700460+ogtega@users.noreply.github.com> Date: Fri, 8 May 2026 09:17:59 -0500 Subject: [PATCH] Add conditional check for `auto_discover` in Ollama provider (#55999) Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #55998 Release Notes: - ollama: Fixed issue where specifying `auto_discover: false` would still auto discover models --- crates/language_models/src/provider/ollama.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/language_models/src/provider/ollama.rs b/crates/language_models/src/provider/ollama.rs index df9f8f383e0a28a15bd9dec03f0297a3146e7f74..ea3a6f65035200b48d58f752123abbce02b7d472 100644 --- a/crates/language_models/src/provider/ollama.rs +++ b/crates/language_models/src/provider/ollama.rs @@ -269,13 +269,15 @@ impl LanguageModelProvider for OllamaLanguageModelProvider { let mut models: HashMap = HashMap::new(); let settings = OllamaLanguageModelProvider::settings(cx); - // Add models from the Ollama API - for model in self.state.read(cx).fetched_models.iter() { - let mut model = model.clone(); - if let Some(context_window) = settings.context_window { - model.max_tokens = context_window; + if settings.auto_discover { + // Add models from the Ollama API + for model in self.state.read(cx).fetched_models.iter() { + let mut model = model.clone(); + if let Some(context_window) = settings.context_window { + model.max_tokens = context_window; + } + models.insert(model.name.clone(), model); } - models.insert(model.name.clone(), model); } // Override with available models from settings