Tool calling not working with phi4-mini model in .NET AI chat application
Description
In C#, the phi4-mini model does not invoke tools when using Microsoft.Extensions.AI's IChatClient with tool calling configured. Switching to a different model "llama3.2" resolves the issue.
Reproduction Steps
- Configure an IChatClient with phi4-mini model in Ollama
- Register a tool using AIFunctionFactory.Create()
- Add the tool to ChatOptions.Tools
- Send a user prompt that should trigger the tool (e.g., "search for X")
- Observe that the model does NOT call the tool
Expected Behavior
Actual Behavior
The model generates a response without calling any tools, even when explicitly instructed to ALWAYS use the tool in the system prompt.
Expected behavior
The model should call the SearchIcmAsync tool when the user asks a question that requires searching, as instructed in the system prompt.
Actual behavior
The model generates a response without calling any tools, even when explicitly instructed to ALWAYS use the tool in the system prompt.
Regression?
No response
Known Workarounds
Using other model
Configuration
No response
Other information
No response
This would be an issue for ollama or the model itself.
You might need to configure tool parser on vLLM for phi4-https://docs.vllm.ai/en/stable/api/vllm/entrypoints/openai/tool_parsers/phi4mini_tool_parser/
I just checked and tried to use gpt-5-chat (on Foundry) which supports tools, but the tools doesn't get called by the model
gpt-5-chat is not recommended for use and may not handle tool calls consistently. This is unrelated to Microsoft.Extensions.AI.
Closing as there's nothing actionable for this repo. If you believe this should be re-opened, please do so with more details. Thanks.