{"record":{"id":"f090027a1ef7e91a","repo":"microsoft/semantic-kernel","slug":"functionchoicebehavior-with-type-function-choice-f09002","errorCode":null,"errorMessage":"FunctionChoiceBehavior with type '{function_choice_behavior.type_}' is not supported for agent invocations. Use FunctionChoiceBehavior.Auto(filters=...) to control which kernel functions are available.","messagePattern":"FunctionChoiceBehavior with type '(.+?)' is not supported for agent invocations\\. Use FunctionChoiceBehavior\\.Auto\\(filters=\\.\\.\\.\\) to control which kernel functions are available\\.","errorType":"exception","errorClass":"AgentInvokeException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/open_ai/assistant_thread_actions.py","lineNumber":882,"sourceCode":"        return {k: str(v) if v is not None else \"\" for k, v in (message.metadata or {}).items()}\n\n    @classmethod\n    def _get_tool_definition(cls: type[_T], tools: list[Any]) -> Iterable[\"AdditionalMessageAttachmentTool\"]:\n        if not tools:\n            return\n        for tool in tools:\n            if tool_definition := cls.tool_metadata.get(tool):\n                yield from tool_definition\n\n    @staticmethod\n    def _validate_function_choice_behavior(\n        function_choice_behavior: FunctionChoiceBehavior | None,\n    ) -> None:\n        \"\"\"Validate the function choice behavior is compatible with agent invocations.\"\"\"\n        if function_choice_behavior is None:\n            return\n        if function_choice_behavior.type_ != FunctionChoiceType.AUTO:\n            raise AgentInvokeException(\n                f\"FunctionChoiceBehavior with type '{function_choice_behavior.type_}' is not supported for agent \"\n                \"invocations. Use FunctionChoiceBehavior.Auto(filters=...) to control which kernel functions \"\n                \"are available.\"\n            )\n        if not function_choice_behavior.auto_invoke_kernel_functions:\n            raise AgentInvokeException(\n                \"FunctionChoiceBehavior.Auto(auto_invoke=False) is not supported for agent invocations. \"\n                \"The agent run loop manages tool invocation; disabling auto_invoke is not compatible.\"\n            )\n        valid_filter_keys: set[str] = {\n            \"excluded_plugins\",\n            \"included_plugins\",\n            \"excluded_functions\",\n            \"included_functions\",\n        }\n        if function_choice_behavior.filters is not None:\n            if not function_choice_behavior.filters:\n                raise AgentInvokeException(","sourceCodeStart":864,"sourceCodeEnd":900,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/open_ai/assistant_thread_actions.py#L864-L900","documentation":"OpenAI Assistant agent invocations only support FunctionChoiceBehavior of type AUTO, because the assistant run loop itself decides when to call tools. Passing a behavior with type Required or None (no-invoke) is rejected by _validate_function_choice_behavior with AgentInvokeException directing you to use FunctionChoiceBehavior.Auto(filters=...).","triggerScenarios":"Constructing FunctionChoiceBehavior.Required() or FunctionChoiceBehavior.NoInvoke() (or a default-constructed behavior whose type is not AUTO) and passing it as function_choice_behavior to an assistant agent invoke/thread-action call.","commonSituations":"Copy-pasting a FunctionChoiceBehavior configured for ChatCompletionPromptExecutionSettings into an agent invoke; assuming Required/None behaviors carry over from the chat-completion API to the Assistants API.","solutions":["Use FunctionChoiceBehavior.Auto(filters=...) for agent invocations; it is the only supported type.","If you wanted to force/forbid tool use, emulate it via filters (included_functions/excluded_functions) rather than the behavior type.","Drop function_choice_behavior entirely to accept the default AUTO behavior with all kernel functions available."],"exampleFix":"// before\nfcb = FunctionChoiceBehavior.Required()\nawait assistant.invoke(kernel=kernel, function_choice_behavior=fcb, thread_id=tid)\n\n// after\nfcb = FunctionChoiceBehavior.Auto(filters={\"included_functions\": [\"math.add\"]})\nawait assistant.invoke(kernel=kernel, function_choice_behavior=fcb, thread_id=tid)","handlingStrategy":"validation","validationCode":"from semantic_kernel.functions import FunctionChoiceBehavior, FunctionChoiceType\n\ndef valid_for_agent(fcb) -> bool:\n    return fcb is None or fcb.type_ == FunctionChoiceType.AUTO","typeGuard":"from semantic_kernel.functions import FunctionChoiceBehavior, FunctionChoiceType\n\ndef is_agent_compatible_fcb(fcb) -> bool:\n    return fcb is None or fcb.type_ == FunctionChoiceType.AUTO","tryCatchPattern":null,"preventionTips":["Only use FunctionChoiceBehavior.Auto for assistant agent invocations.","Do not reuse chat-completion Required/None behaviors with agents.","Control tool availability via filters, not behavior type."],"tags":["openai","assistant","function-choice-behavior","validation","agentinvoke"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}