OllamaSharp.Models.Exceptions.ModelDoesNotSupportToolsException:
registry.ollama.ai/library/gemma3:12b does not support tools means you sent a chat
request with tools to a model that Ollama cannot run with tools. Your code is fine; pick a
model that supports tool calling, such as qwen2.5:3b.
Change only the model name. The same UseFunctionInvocation() pipeline and the
same AIFunctionFactory.Create tool then work, and the model calls your method.
The error
Unhandled exception. OllamaSharp.Models.Exceptions.ModelDoesNotSupportToolsException: registry.ollama.ai/library/gemma3:12b does not support tools
at OllamaSharp.OllamaApiClient.EnsureSuccessStatusCodeAsync(HttpResponseMessage response)
Why it happens
A model in Ollama can take tools only when its chat template knows how to describe them to
the model and how to read a tool call back. When a request carries a tools
list and the model's template has no such support, the server rejects the request before
generating anything. OllamaSharp reads that rejection and throws its own
ModelDoesNotSupportToolsException, with the model's full registry name in the
message.
Gemma 3 is a capable chat model, which is what makes this confusing: it answers ordinary prompts well, and the failure appears only once you add a tool. The function-invocation middleware from Microsoft.Extensions.AI is not the cause; it simply passes your tools on to the client.
The fix
IChatClient ollama = new OllamaApiClient(new Uri(baseUrl), model);
IChatClient client = new ChatClientBuilder(ollama)
.UseFunctionInvocation()
.Build();
var options = new ChatOptions
{
Tools = [AIFunctionFactory.Create(GetOpenSlots)]
};
var reply = await client.GetResponseAsync(
"How many appointment slots are open on Friday? Use the tool.", options);
Console.WriteLine(reply.Text);
PS> dotnet run --no-build -- qwen2.5:3b http://localhost:11434 tool
[tool] GetOpenSlots(weekday: Friday)
There are 3 open appointment slots available on Friday.
The code is unchanged between the failing and the working run; only the model argument
moved from gemma3:12b to qwen2.5:3b. The first output line is
printed by the tool method itself, which proves the model called it. On the Ollama library
site, models that support tool calling carry a "tools" label; check it before you choose a
model for an agent. If you need Gemma for its answers, keep it for plain chat and route
tool-using requests to a second client on a tool-capable model.
How it was reproduced
A console app from dotnet new console -n FixLab -f net10.0 on .NET SDK
10.0.401, with Microsoft.Extensions.AI 10.10.0 and OllamaSharp 5.5.0, against Ollama 0.40.1
on Windows 11. The tool is a small static method, GetOpenSlots(string weekday),
with fictional data. The program takes the model name, base URL and mode from its
arguments, so both runs used the same build: gemma3:12b failed as shown and
qwen2.5:3b answered. The stack trace above is cut after its first frame.
Frequently asked
- Why does Ollama say a model does not support tools?
- The request included a tools list and the model's chat template has no tool-calling support, so the server rejects it. Use a model that supports tools, such as qwen2.5.
- Which Ollama models support tool calling?
- On the Ollama library site, models with tool support carry a tools label. In this test qwen2.5:3b called the tool and gemma3:12b was rejected.
- Is ModelDoesNotSupportToolsException a bug in OllamaSharp or Microsoft.Extensions.AI?
- No. OllamaSharp turns the server's rejection into this exception. The code is correct; changing only the model name to a tool-capable one makes the same code work.
More decoded errors in the Fixes category.