You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: Bug: Ollama connector drops the plugin name from assistant tool calls in chat history #14748
Describe the bug OllamaChatCompletion advertises tools to Ollama by their fully qualified name, for example Weather-get_weather. When it formats the chat history for the next request, _format_assistant_message in semantic_kernel/connectors/ai/ollama/services/utils.py sends each assistant tool call back with only function_name (get_weather). The tool calls in the history then do not match any tool in the request. This happens on every follow-up request after an automatic function call to a plugin function.
Other connectors, such as Bedrock and Google, send the fully qualified name.
To Reproduce
No Ollama server is needed:
fromsemantic_kernel.connectors.ai.ollamaimportOllamaChatCompletionfromsemantic_kernel.contentsimportChatHistory, ChatMessageContent, FunctionCallContent, FunctionResultContentfromsemantic_kernel.contents.utils.author_roleimportAuthorRoleservice=OllamaChatCompletion(ai_model_id="llama3.2", host="http://localhost:11434")
history=ChatHistory()
history.add_user_message("What is the weather in Paris?")
call=FunctionCallContent(id="call_1", name="Weather-get_weather", arguments={"city": "Paris"})
history.add_message(ChatMessageContent(role=AuthorRole.ASSISTANT, items=[call]))
history.add_message(
ChatMessageContent(
role=AuthorRole.TOOL,
items=[FunctionResultContent.from_function_call_content_and_result(call, "Sunny, 21C")],
)
)
messages=service._prepare_chat_history_for_request(history)
print(messages[1]["tool_calls"][0]["function"]["name"])
Expected behavior
Prints Weather-get_weather, the same name the tool was declared with.
Actual behavior
Prints get_weather.
Platform
Language: Python
Source: semantic-kernel 1.47.0, upstream main at df1cb33
AI model: any Ollama model with tool calling
IDE: n/a
OS: Linux, Python 3.14.10
Additional context
The fix is a one-line change to use tool_call.name, falling back to tool_call.function_name when no name is set. I would like to take this one and will open a PR.
Activity