microsoft/semantic-kernel · error · ServiceInvalidExecutionSettingsError
Ollama does not support function choice behavior of type 're
Error message
Ollama does not support function choice behavior of type 'required' or 'none' yet.
What it means
Raised as ServiceInvalidExecutionSettingsError (a subclass of ServiceResponseException) in `_verify_function_choice_settings` when the configured `settings.function_choice_behavior.type_` is FunctionChoiceType.REQUIRED or FunctionChoiceType.NONE. The current Ollama connector only supports AUTO (or none) for tool/function calling; 'required' (force a tool call) and 'none' (forbid tools) are not implemented against the Ollama API.
Source
Thrown at python/semantic_kernel/connectors/ai/ollama/services/ollama_chat_completion.py:133
return str(self.client._client.base_url)
return None
@override
def _prepare_chat_history_for_request(
self,
chat_history: ChatHistory,
role_key: str = "role",
content_key: str = "content",
) -> list[Message]:
return [MESSAGE_CONVERTERS[message.role](message) for message in chat_history.messages]
@override
def _verify_function_choice_settings(self, settings: "PromptExecutionSettings") -> None:
if settings.function_choice_behavior and settings.function_choice_behavior.type_ in [
FunctionChoiceType.REQUIRED,
FunctionChoiceType.NONE,
]:
raise ServiceInvalidExecutionSettingsError(
"Ollama does not support function choice behavior of type 'required' or 'none' yet."
)
@override
def _update_function_choice_settings_callback(
self,
) -> Callable[["FunctionCallChoiceConfiguration", "PromptExecutionSettings", FunctionChoiceType], None]:
return update_settings_from_function_choice_configuration
@override
def _reset_function_choice_settings(self, settings: "PromptExecutionSettings") -> None:
if hasattr(settings, "tools"):
settings.tools = None
@override
@trace_chat_completion(OllamaBase.MODEL_PROVIDER_NAME)
async def _inner_get_chat_message_contents(
self,View on GitHub (pinned to c028a0c7dc)
Solutions
- Use FunctionChoiceBehavior.Auto (or omit the behavior) for Ollama tool calling.
- If you need required/none semantics, switch to a connector that supports them (OpenAI/Azure) or remove tools from the request.
- Gating: check the service type before applying required/none behavior.
Example fix
# before from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior settings.function_choice_behavior = FunctionChoiceBehavior.Required() # after - Auto is supported by Ollama settings.function_choice_behavior = FunctionChoiceBehavior.Auto(auto_invoke=True)
Defensive patterns
Strategy: validation
Validate before calling
from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior
from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceType
if isinstance(svc, OllamaChatCompletion):
fcb = settings.function_choice_behavior
assert not fcb or fcb.type_ == FunctionChoiceType.AUTO, \
'Ollama supports only Auto function choice behavior' Type guard
from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceType
def is_ollama_supported_fcb(settings) -> bool:
fcb = getattr(settings, 'function_choice_behavior', None)
return not fcb or fcb.type_ == FunctionChoiceType.AUTO Try / catch
from semantic_kernel.exceptions import ServiceInvalidExecutionSettingsError
try:
await svc.get_chat_message_contents(chat_history, settings)
except ServiceInvalidExecutionSettingsError as e:
if "does not support function choice behavior" in str(e):
settings.function_choice_behavior = None # or Auto
await svc.get_chat_message_contents(chat_history, settings)
else:
raise Prevention
- Use FunctionChoiceBehavior.Auto (or no tools) for Ollama; required/none are unsupported.
- When porting OpenAI/Azure configs to Ollama, downgrade function choice behavior.
- Gate tool/behavior config on the connector type before applying.
When it happens
Trigger: Configuring the chat settings / prompt execution with `FunctionChoiceBehavior.Required` or `FunctionChoiceBehavior.None` (or required=True / type_='required') and then invoking chat on an OllamaChatCompletion service. The check runs during settings verification, before the request is sent.
Common situations: Porting an OpenAI/Azure agent config (which supports required/none) to Ollama unchanged; using the kernel's function-calling auto-invoke with a required behavior; explicitly disabling tools with FunctionChoiceType.NONE.
Related errors
- The kernel is required for function calls.
- AI Chat Service type '{appConfig.RagConfig.AIChatService}' i
- Invalid execution settings, cannot convert to OllamaPromptEx
- Tool choice 'none' is not supported by Anthropic.
- Failed to create Ollama settings.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/4da31b50b00bb02e.
Report an issue: GitHub.