{"record":{"id":"08548eb6e11b52a7","repo":"microsoft/semantic-kernel","slug":"tool-choice-none-is-not-supported-by-anthropic","errorCode":null,"errorMessage":"Tool choice 'none' is not supported by Anthropic.","messagePattern":"Tool choice 'none' is not supported by Anthropic\\.","errorType":"exception","errorClass":"ServiceInvalidExecutionSettingsError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/anthropic/prompt_execution_settings/anthropic_prompt_execution_settings.py","lineNumber":53,"sourceCode":"            description=(\n                \"Do not set this manually. It is set by the service based on the function choice configuration.\"\n            ),\n        ),\n    ] = None\n    tool_choice: Annotated[\n        dict[str, str] | None,\n        Field(\n            description=\"Do not set this manually. It is set by the service based on the function choice configuration.\"\n        ),\n    ] = None\n\n    @model_validator(mode=\"after\")\n    def validate_tool_choice(self) -> \"AnthropicChatPromptExecutionSettings\":\n        \"\"\"Validate tool choice. Anthropic doesn't support NONE tool choice.\"\"\"\n        tool_choice = self.tool_choice\n\n        if tool_choice and tool_choice.get(\"type\") == FunctionChoiceType.NONE.value:\n            raise ServiceInvalidExecutionSettingsError(\"Tool choice 'none' is not supported by Anthropic.\")\n\n        return self\n","sourceCodeStart":35,"sourceCodeEnd":56,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/anthropic/prompt_execution_settings/anthropic_prompt_execution_settings.py#L35-L56","documentation":"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.","triggerScenarios":"Configuring an Anthropic chat with function_choice_behavior/tool_choice set to NONE, or passing tool_choice={\"type\": \"none\"} in the execution settings.","commonSituations":"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.","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."],"exampleFix":"// before\nsettings = AnthropicChatPromptExecutionSettings()\nsettings.tool_choice = {\"type\": \"none\"}  # rejected\n\n// after\nsettings.tool_choice = {\"type\": \"auto\"}\n# or leave tool_choice unset and provide no tools to suppress tool use","handlingStrategy":"validation","validationCode":"from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceType\ntc = settings.tool_choice\nif tc and tc.get('type') == FunctionChoiceType.NONE.value:\n    raise ValueError('Anthropic does not support tool_choice NONE; use AUTO/REQUIRED or omit tools')","typeGuard":"def is_anthropic_compatible_tool_choice(tool_choice: dict | None) -> bool:\n    if not tool_choice:\n        return True\n    return tool_choice.get('type') != FunctionChoiceType.NONE.value","tryCatchPattern":null,"preventionTips":["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"],"tags":["anthropic","tools","function-calling","config"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}