microsoft/semantic-kernel · error · ServiceInvalidExecutionSettingsError
Tool choice 'none' is not supported by Anthropic.
Error message
Tool choice 'none' is not supported by Anthropic.
What it means
AnthropicChatPromptExecutionSettings.validate_tool_choice (a pydantic model_validator) raises ServiceInvalidExecutionSettingsError when tool_choice is present and its type equals FunctionChoiceType.NONE. The Anthropic Messages API has no 'none' tool-choice mode, so the connector rejects the configuration before any request.
Source
Thrown at python/semantic_kernel/connectors/ai/anthropic/prompt_execution_settings/anthropic_prompt_execution_settings.py:53
description=(
"Do not set this manually. It is set by the service based on the function choice configuration."
),
),
] = None
tool_choice: Annotated[
dict[str, str] | None,
Field(
description="Do not set this manually. It is set by the service based on the function choice configuration."
),
] = None
@model_validator(mode="after")
def validate_tool_choice(self) -> "AnthropicChatPromptExecutionSettings":
"""Validate tool choice. Anthropic doesn't support NONE tool choice."""
tool_choice = self.tool_choice
if tool_choice and tool_choice.get("type") == FunctionChoiceType.NONE.value:
raise ServiceInvalidExecutionSettingsError("Tool choice 'none' is not supported by Anthropic.")
return self
View on GitHub (pinned to c028a0c7dc)
Solutions
- Use AUTO or REQUIRED for Anthropic, or omit tool_choice entirely.
- To avoid tool use, simply do not register/pass any tools rather than selecting NONE.
- Branch the function-choice behavior per provider so NONE is never sent to Anthropic.
Example fix
// before
settings = AnthropicChatPromptExecutionSettings()
settings.tool_choice = {"type": "none"} # rejected
// after
settings.tool_choice = {"type": "auto"}
# or leave tool_choice unset and provide no tools to suppress tool use Defensive patterns
Strategy: validation
Validate before calling
from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceType
tc = settings.tool_choice
if tc and tc.get('type') == FunctionChoiceType.NONE.value:
raise ValueError('Anthropic does not support tool_choice NONE; use AUTO/REQUIRED or omit tools') Type guard
def is_anthropic_compatible_tool_choice(tool_choice: dict | None) -> bool:
if not tool_choice:
return True
return tool_choice.get('type') != FunctionChoiceType.NONE.value Prevention
- Branch function-choice behavior per provider; never send NONE to Anthropic
- To suppress tools, pass no tools rather than choosing NONE
- Validate settings before invoking completion
When it happens
Trigger: Configuring an Anthropic chat with function_choice_behavior/tool_choice set to NONE, or passing tool_choice={"type": "none"} in the execution settings.
Common situations: Sharing/reusing a function-choice configuration across providers and carrying a NONE setting onto Anthropic; explicitly disabling tools by choosing NONE; defaulting to NONE in a generic helper.
Related errors
- Failed to create Anthropic settings.
- The Anthropic chat model ID is required.
- Tool message found without a preceding message.
- Tool message found after a user or system message.
- Ollama does not support function choice behavior of type 're
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/08548eb6e11b52a7.
Report an issue: GitHub.