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
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=...).
Source
Thrown at python/semantic_kernel/agents/open_ai/assistant_thread_actions.py:882
return {k: str(v) if v is not None else "" for k, v in (message.metadata or {}).items()}
@classmethod
def _get_tool_definition(cls: type[_T], tools: list[Any]) -> Iterable["AdditionalMessageAttachmentTool"]:
if not tools:
return
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(View on GitHub (pinned to c028a0c7dc)
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.
Example fix
// before
fcb = FunctionChoiceBehavior.Required()
await assistant.invoke(kernel=kernel, function_choice_behavior=fcb, thread_id=tid)
// after
fcb = FunctionChoiceBehavior.Auto(filters={"included_functions": ["math.add"]})
await assistant.invoke(kernel=kernel, function_choice_behavior=fcb, thread_id=tid) Defensive patterns
Strategy: validation
Validate before calling
from semantic_kernel.functions import FunctionChoiceBehavior, FunctionChoiceType
def valid_for_agent(fcb) -> bool:
return fcb is None or fcb.type_ == FunctionChoiceType.AUTO Type guard
from semantic_kernel.functions import FunctionChoiceBehavior, FunctionChoiceType
def is_agent_compatible_fcb(fcb) -> bool:
return fcb is None or fcb.type_ == FunctionChoiceType.AUTO Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- FunctionChoiceBehavior.Auto(auto_invoke=False) is not suppor
- FunctionChoiceBehavior filters must not be empty. Provide at
- Unknown filter key(s): {sorted(unknown_keys)}. Valid filter
- Invalid message role `{message.role.value}`. Allowed roles a
- Invalid message role `{message.role.value}`. Allowed roles a
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/f090027a1ef7e91a.
Report an issue: GitHub.