extensions icon indicating copy to clipboard operation
extensions copied to clipboard

Tool calling not working with phi4-mini model in .NET AI chat application

Open siyavash1984 opened this issue 1 year ago • 5 comments

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

  1. Configure an IChatClient with phi4-mini model in Ollama
  2. Register a tool using AIFunctionFactory.Create()
  3. Add the tool to ChatOptions.Tools
  4. Send a user prompt that should trigger the tool (e.g., "search for X")
  5. 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

siyavash1984 avatar Dec 01 '25 02:12 siyavash1984

This would be an issue for ollama or the model itself.

stephentoub avatar Dec 01 '25 02:12 stephentoub

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/

atakanertrk avatar Dec 02 '25 08:12 atakanertrk

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

siyavash1984 avatar Dec 09 '25 01:12 siyavash1984

gpt-5-chat is not recommended for use and may not handle tool calls consistently. This is unrelated to Microsoft.Extensions.AI.

stephentoub avatar Dec 10 '25 03:12 stephentoub

Closing as there's nothing actionable for this repo. If you believe this should be re-opened, please do so with more details. Thanks.

stephentoub avatar Dec 10 '25 03:12 stephentoub