{"record":{"id":"7c41ff9ebb6e217d","repo":"microsoft/semantic-kernel","slug":"functionchoicebehavior-auto-auto-invoke-false-is-7c41ff","errorCode":null,"errorMessage":"FunctionChoiceBehavior.Auto(auto_invoke=False) is not supported for agent invocations. The agent run loop manages tool invocation; disabling auto_invoke is not compatible.","messagePattern":"FunctionChoiceBehavior\\.Auto\\(auto_invoke=False\\) is not supported for agent invocations\\. The agent run loop manages tool invocation; disabling auto_invoke is not compatible\\.","errorType":"exception","errorClass":"AgentInvokeException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/open_ai/assistant_thread_actions.py","lineNumber":888,"sourceCode":"        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(\n                    \"FunctionChoiceBehavior filters must not be empty. Provide at least one filter key \"\n                    f\"from {sorted(valid_filter_keys)}, or omit filters entirely to include all \"\n                    \"kernel functions.\"\n                )\n            unknown_keys = {str(k) for k in function_choice_behavior.filters} - valid_filter_keys\n            if unknown_keys:","sourceCodeStart":870,"sourceCodeEnd":906,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/open_ai/assistant_thread_actions.py#L870-L906","documentation":"Even when the type is AUTO, the agent run loop manages tool invocation itself, so auto_invoke_kernel_functions must be True. FunctionChoiceBehavior.Auto(auto_invoke_kernel_functions=False) is therefore rejected with AgentInvokeException because disabling auto-invoke is incompatible with the agent-managed run loop.","triggerScenarios":"Constructing FunctionChoiceBehavior.Auto(auto_invoke_kernel_functions=False) (or setting the attribute False) and passing it to an assistant agent invoke / thread-action call.","commonSituations":"Wanting to inspect/intercept each function call manually (as in chat completion) and disabling auto-invoke, not realizing the assistant run loop must drive tool execution.","solutions":["Keep auto_invoke_kernel_functions=True (the default) for agent invocations; let the run loop execute tools.","To control which tools run, use filters (included/excluded functions/plugins) instead of disabling auto-invoke.","Omit function_choice_behavior entirely if you do not need filtering."],"exampleFix":"// before\nfcb = FunctionChoiceBehavior.Auto(auto_invoke_kernel_functions=False)\nawait assistant.invoke(kernel=kernel, function_choice_behavior=fcb, thread_id=tid)\n\n// after\nfcb = FunctionChoiceBehavior.Auto()  # auto_invoke defaults True\nawait assistant.invoke(kernel=kernel, function_choice_behavior=fcb, thread_id=tid)","handlingStrategy":"validation","validationCode":"def auto_invoke_ok(fcb) -> bool:\n    return fcb is None or fcb.auto_invoke_kernel_functions is True","typeGuard":"def is_auto_invoke_enabled(fcb) -> bool:\n    return fcb is None or getattr(fcb, 'auto_invoke_kernel_functions', True) is True","tryCatchPattern":null,"preventionTips":["Keep auto_invoke_kernel_functions=True (default) for agents.","Restrict tools via filters instead of disabling auto-invoke.","Omit function_choice_behavior if you do not need filtering."],"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"}