From 63b3839a83984a48ef57e96253f3602c16cf22b3 Mon Sep 17 00:00:00 2001 From: Umesh Yadav <23421535+imumesh18@users.noreply.github.com> Date: Wed, 3 Sep 2025 04:58:36 +0530 Subject: [PATCH] language_models: Prevent sending the tools object to unsupported models for Ollama (#37221) Closes #32758 Release Notes: - Resolved an issue with the Ollama provider that caused requests to fail with a 400 error for models that don't support tools. The tools object is now only sent to compatible models to ensure successful requests. --- crates/language_models/src/provider/ollama.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/language_models/src/provider/ollama.rs b/crates/language_models/src/provider/ollama.rs index 3f2d47fba35959e6c26205193dddba45c2df25cc..8975115d907875569f63e4247cf7edcdbcb91f8a 100644 --- a/crates/language_models/src/provider/ollama.rs +++ b/crates/language_models/src/provider/ollama.rs @@ -347,7 +347,11 @@ impl OllamaLanguageModel { .model .supports_thinking .map(|supports_thinking| supports_thinking && request.thinking_allowed), - tools: request.tools.into_iter().map(tool_into_ollama).collect(), + tools: if self.model.supports_tools.unwrap_or(false) { + request.tools.into_iter().map(tool_into_ollama).collect() + } else { + vec![] + }, } } }