Skip to content

Python: fix Ollama connector dropping plugin name from assistant tool calls - #14836

Open
Santosh Todkar (todkarsant) wants to merge 2 commits into
microsoft:mainfrom
todkarsant:fix/ollama-tool-call-fqn
Open

Santosh Todkar (todkarsant) wants to merge 2 commits into
microsoft:mainfrom
todkarsant:fix/ollama-tool-call-fqn

Conversation

@todkarsant

Copy link
Copy Markdown

Motivation and Context

_format_assistant_message sends tool_call.function_name (get_weather) instead of tool_call.name (Weather-get_weather). The tool calls in chat history then do not match any declared tool, breaking follow-up requests after automatic function calls to plugin functions.

Description

Use tool_call.name (the fully qualified name) with a fallback to tool_call.function_name when name is not set.

Closes #14748

_format_assistant_message sent tool_call.function_name ("get_weather")
instead of tool_call.name ("Weather-get_weather").  The tool calls in
chat history then did not match any declared tool, breaking follow-up
requests after automatic function calls to plugin functions.

Fixes microsoft#14748
@todkarsant

Copy link
Copy Markdown
Author

Eduard van Valkenburg (@eavanvalkenburg) Darren Cohen (@dargilco) Could you review this one-line fix? It restores the fully qualified tool name in the Ollama connector's assistant message formatting — context from #14748.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A regression test is still needed to verify that replaying a qualified function call preserves its full name, since the existing test covers only the fallback path.

1 open issue
What changed in this PR

Fixes #14748 by preserving plugin-qualified tool names when the Ollama connector replays assistant calls, keeping chat history consistent with declared tools.

Changes:

  • Prefer tool_call.name to retain the plugin prefix.
  • Fall back to tool_call.function_name when name is unset.
File Description
python/​semantic_kernel/​connectors/​ai/​ollama/​services/​utils.py Preserves qualified tool names during assistant-message serialization.

Review effort: Balanced

{
"function": {
"name": tool_call.function_name,
"name": tool_call.name or tool_call.function_name,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already included — test_message_converters_assistant_with_qualified_tool_call_name (lines 169–187 in this diff) creates a FunctionCallContent(name="Weather-get_weather", ...) and asserts the serialized name remains "Weather-get_weather".

Covers the case where FunctionCallContent is created with a fully
qualified name (e.g. "Weather-get_weather").  The existing test only
exercises the fallback path via function_name.

This branch was previously deployed

1 inactive deployment
github-app-auth — f96c874a Deployed Nov 20, 2026 by todkarsant via add_label #29763
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Bug: Ollama connector drops the plugin name from assistant tool calls in chat history

2 participants