.Net: Bug: .Net, Since package version 1.63.0, when using Ollama + gpt-oss:20b, the function calling feature does not work properly in streaming mode.
Describe the bug Since package version 1.63.0, when using Ollama + gpt-oss:20b, the function calling feature does not work properly in streaming mode. Instead of being invoked as expected, it directly terminates.
To Reproduce Steps to reproduce the behavior:
- Target the semantick kernel version to 1.63.0
- Add a plugin to kernel, e.g: builder.Plugins.AddFromType<YOUR_PLUGIN_TYPE>();
- Add OllamaChatCompletion with model gpt-oss:20b
- Start a async chat (GetStreamingChatMessageContentsAsync) that should trigger the function call added above.
- The entire chat session end immediately after a tool call request appears, without executing the tool call.
Expected behavior The tool should be invoked properly, and the response should be generated based on the results returned from the tool call.
Platform
- Language: C#
- Source: nuget package (1.63.0)
- AI model: ollama 0.11.7 + gpt-oss:20b
- IDE: Rider
- OS: Mac
Additional context I tested both versions 1.63.0 and 1.64.0, and the same issue occurs in both. However, in versions 1.62.0 and 1.61.0, the tool calls work correctly as expected.
I'm testing GPT-5 and i'm having same issue. it's only returning empty object when calling any plugins. I can see the plugin return response to the AI.
This seems to be related to a bug in the OllamaSharp library specificaly to the OpenAI OSS model, the fix below may solve the issue.
As soon they have an update we will upgrade our dependency.
- https://github.com/awaescher/OllamaSharp/issues/305
Running our Demo with older models like llama3.1+ worked for both streaming and non-streaming.
@rogerbarreto any news?
I have same issue on tool calls with Semantic Kernel 1.65 + Ollama or Vllm with GPT-OSS:lates models. With other models like Qween works correctly, buth with GPT-OSS doesn't work correctly. I've tested function calls by curl and works correctly both in vllm and ollama, seems that semantic kernel can't handle it. Please help!!!
The current release (1.65.0) references OllamaSharp package version >= 5.3.5, which contains an issue when running ollama with gpt-oss models (reference) .
OllamaSharp fixed this issue in version 5.3.12 and later. It is anticipated that SK will update the OllamaSharp dependency in the next release. I have tested manually upgrading the OllamaSharp dependency, and it works as expected. For urgent needs, the workaround is to manually add the OllamaSharp dependency to your project and target version 5.3.12.
Hope this helped.
@rogerbarreto Hi, I saw that version 1.66.0 of Semantic Kernel has been released, but the dependency of OllamaSharp still targets 5.3.5. Will it be changed in the next release ?
Hi, I've tried @bauann solution, and it doesn't work on my computer. The problem isn't limited to gpt-oss:20b, either. I've also tried mistral-nemo:12b-instruct-2407-q4_K_M and jacob-ebey/phi4-tools:latest. However, it does work correctly with LLM llama3.1 and the OllamaSharp 5.3.5 nuget package.
Hi @jesusSerranoCarballido , this issue likely occurs in the context of gpt-oss + ollama. I conducted a test with my current setup, which uses llama3.1 + ollama (0.12.6) + SK (1.66.0). Even with OllamaSharp remaining at the default version of 5.3.5, the function calling works as expected.
I recommend checking the following:
- ollama version (upgrade to the latest version)
- Check your code for the promptExecutionSetting configuration, for example:
return new OllamaPromptExecutionSettings()
{
Temperature = 0.1f,
FunctionChoiceBehavior = isEnableToolUse ? FunctionChoiceBehavior.Auto() : null,
};
Since the latest version of SK (1.68.0) has changed the dependency of OllamaSharp to version 5.4.11, this issue no longer exists.