microsoft/semantic-kernel · error · AgentInvokeException
FunctionChoiceBehavior with type '{function_choice_behavior.
Error message
FunctionChoiceBehavior with type '{function_choice_behavior.type_}' is not supported for agent invocations. Use FunctionChoiceBehavior.Auto(filters=...) to control which kernel functions are available. What it means
Raised when an AzureAIAgent invocation is given a FunctionChoiceBehavior whose type_ is not FunctionChoiceType.AUTO. The Azure AI agent run loop is hardwired to auto-invoke tools, so only the Auto behavior is compatible; other types (None/Required) would hand control to the caller in a way the loop cannot honor.
Source
Thrown at python/semantic_kernel/agents/azure_ai/agent_thread_actions.py:992
tool["openapi"] = openapi_data
return tool
@staticmethod
def _deduplicate_tools(existing_tools: list[dict], new_tools: list[dict]) -> list[dict]:
existing_names = {
tool["function"]["name"] for tool in existing_tools if "function" in tool and "name" in tool["function"]
}
return [tool for tool in new_tools if tool.get("function", {}).get("name") not in existing_names]
@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(View on GitHub (pinned to c028a0c7dc)
Solutions
- Switch to FunctionChoiceBehavior.Auto(filters=...) with the desired included_plugins/included_functions/excluded_plugins/excluded_functions to control tool availability.
- Remove the FunctionChoiceBehavior argument entirely — the agent run loop defaults to exposing all registered kernel functions.
- If you need required/no-tool semantics, do not use AzureAIAgent; those behaviors are not supported by the hosted run loop.
Example fix
// before
behavior = FunctionChoiceBehavior.Required()
await agent.invoke(thread, messages=..., function_choice_behavior=behavior)
// after
behavior = FunctionChoiceBehavior.Auto(
filters={"included_functions": ["MyPlugin-MyFunc"]}
)
await agent.invoke(thread, messages=..., function_choice_behavior=behavior) Defensive patterns
Strategy: validation
Validate before calling
from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior, FunctionChoiceType
def is_agent_compatible(behavior) -> bool:
return behavior is None or behavior.type_ == FunctionChoiceType.AUTO
# before invoking
if not is_agent_compatible(fcb):
fcb = FunctionChoiceBehavior.Auto() Type guard
from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior, FunctionChoiceType
def is_auto_behavior(b: object) -> bool:
return (
b is None
or (isinstance(b, FunctionChoiceBehavior) and b.type_ == FunctionChoiceType.AUTO)
) Try / catch
from semantic_kernel.exceptions import AgentInvokeException
try:
await agent.invoke(thread, function_choice_behavior=fcb)
except AgentInvokeException as e:
if "not supported for agent invocations" in str(e):
fcb = FunctionChoiceBehavior.Auto()
await agent.invoke(thread, function_choice_behavior=fcb)
else:
raise Prevention
- Centralize FunctionChoiceBehavior construction in a helper that always returns Auto for AzureAIAgent calls.
- Add a unit test asserting any behavior passed to AzureAIAgent has type_ == FunctionChoiceType.AUTO.
When it happens
Trigger: Passing FunctionChoiceBehavior.Required() or FunctionChoiceBehavior.NoneInvoke() (or any non-AUTO type) as the function_choice_behavior argument to AzureAIAgent.invoke()/invoke_stream, or setting it on the ChatHistory/PromptExecutionSettings used by the agent.
Common situations: Developer copies a FunctionChoiceBehavior setup from a non-agent chat flow (e.g. ChatCompletionAgent or kernel.invoke_async) into an AzureAIAgent call, expecting the same behavior mapping. Also occurs after upgrading when FunctionChoiceBehavior replaced the older None auto_invoke kwargs.
Related errors
- Unknown filter key(s): {sorted(unknown_keys)}. Valid filter
- FunctionChoiceBehavior.Auto(auto_invoke=False) is not suppor
- FunctionChoiceBehavior filters must not be empty. Provide at
- Missing or malformed 'tool_connections' in: {spec}
- Missing or malformed 'index_name' in: {spec}
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/2eb4b99b8a25e070.
Report an issue: GitHub.