microsoft/semantic-kernel · error · AgentInvokeException

FunctionChoiceBehavior.Auto(auto_invoke=False) is not suppor

Error message

FunctionChoiceBehavior.Auto(auto_invoke=False) is not supported for agent invocations. The agent run loop manages tool invocation; disabling auto_invoke is not compatible.

What it means

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.

Source

Thrown at python/semantic_kernel/agents/open_ai/assistant_thread_actions.py:888

        for tool in tools:
            if tool_definition := cls.tool_metadata.get(tool):
                yield from tool_definition

    @staticmethod
    def _validate_function_choice_behavior(
        function_choice_behavior: FunctionChoiceBehavior | None,
    ) -> None:
        """Validate the function choice behavior is compatible with agent invocations."""
        if function_choice_behavior is None:
            return
        if function_choice_behavior.type_ != FunctionChoiceType.AUTO:
            raise AgentInvokeException(
                f"FunctionChoiceBehavior with type '{function_choice_behavior.type_}' is not supported for agent "
                "invocations. Use FunctionChoiceBehavior.Auto(filters=...) to control which kernel functions "
                "are available."
            )
        if not function_choice_behavior.auto_invoke_kernel_functions:
            raise AgentInvokeException(
                "FunctionChoiceBehavior.Auto(auto_invoke=False) is not supported for agent invocations. "
                "The agent run loop manages tool invocation; disabling auto_invoke is not compatible."
            )
        valid_filter_keys: set[str] = {
            "excluded_plugins",
            "included_plugins",
            "excluded_functions",
            "included_functions",
        }
        if function_choice_behavior.filters is not None:
            if not function_choice_behavior.filters:
                raise AgentInvokeException(
                    "FunctionChoiceBehavior filters must not be empty. Provide at least one filter key "
                    f"from {sorted(valid_filter_keys)}, or omit filters entirely to include all "
                    "kernel functions."
                )
            unknown_keys = {str(k) for k in function_choice_behavior.filters} - valid_filter_keys
            if unknown_keys:

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Keep auto_invoke_kernel_functions=True (the default) for agent invocations; let the run loop execute tools.
  2. To control which tools run, use filters (included/excluded functions/plugins) instead of disabling auto-invoke.
  3. Omit function_choice_behavior entirely if you do not need filtering.

Example fix

// before
fcb = FunctionChoiceBehavior.Auto(auto_invoke_kernel_functions=False)
await assistant.invoke(kernel=kernel, function_choice_behavior=fcb, thread_id=tid)

// after
fcb = FunctionChoiceBehavior.Auto()  # auto_invoke defaults True
await assistant.invoke(kernel=kernel, function_choice_behavior=fcb, thread_id=tid)
Defensive patterns

Strategy: validation

Validate before calling

def auto_invoke_ok(fcb) -> bool:
    return fcb is None or fcb.auto_invoke_kernel_functions is True

Type guard

def is_auto_invoke_enabled(fcb) -> bool:
    return fcb is None or getattr(fcb, 'auto_invoke_kernel_functions', True) is True

Prevention

When it happens

Trigger: Constructing FunctionChoiceBehavior.Auto(auto_invoke_kernel_functions=False) (or setting the attribute False) and passing it to an assistant agent invoke / thread-action call.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/7c41ff9ebb6e217d. Report an issue: GitHub.