Heuristic:Microsoft Semantic kernel Function Choice Behavior Selection
| Knowledge Sources | |
|---|---|
| Domains | AI_Orchestration, Function_Calling |
| Last Updated | 2026-02-11 20:00 GMT |
Overview
Decision framework for selecting between Auto, Required, and None function choice behaviors when configuring AI model function calling in Semantic Kernel.
Description
Semantic Kernel provides three distinct FunctionChoiceBehavior modes that control how an AI model interacts with registered plugin functions. Each mode serves a specific purpose: Auto lets the model decide whether and which functions to call, Required forces the model to call functions and then stops advertising them to prevent infinite loops, and None prevents function execution but allows the model to describe what it would call. Choosing the wrong mode leads to either no function calls when expected, repeated function calls in loops, or unnecessary API costs.
Usage
Use this heuristic whenever configuring PromptExecutionSettings with function calling enabled. This is relevant for all implementations that use plugins with AI chat completion, including agent invocations, prompt-with-function workflows, and orchestration patterns.
The Insight (Rule of Thumb)
- Default choice: Use
FunctionChoiceBehavior.Auto()for most scenarios. The model decides whether to call functions. - Force a single round: Use
FunctionChoiceBehavior.Required()when you need the model to call functions exactly once. SK connectors automatically stop advertising functions after the first invocation to prevent repeated calls. - Validation without execution: Use
FunctionChoiceBehavior.None()to see which functions the model would call without executing them. Useful for testing and approval workflows. - Trade-off: Auto is flexible but may skip functions. Required guarantees function calls but adds the overhead of stopping advertisement. None adds latency for an extra round-trip without actual function execution.
- autoInvoke parameter: Set
autoInvoke: true(default) to let SK connectors handle function invocation automatically. SetautoInvoke: falseif you need to manually invoke returned function calls.
Reasoning
The three-mode design addresses a fundamental tension in AI function calling. Models do not always call functions when expected (Auto is flexible but unpredictable). Forcing function calls (Required) risks infinite loops if the model repeatedly requests the same function. The Required behavior in SK connectors solves this by stopping function advertisement after the first successful invocation. The None mode exists specifically for human-in-the-loop and approval patterns where you want to validate the model's decisions before executing them.
The autoInvoke parameter provides additional control: when set to false, the connector returns the function call information without executing it, allowing custom invocation logic, logging, or approval gates.
Code Evidence
Three modes defined in dotnet/src/SemanticKernel.Abstractions/AI/FunctionChoiceBehaviors/FunctionChoiceBehavior.cs:62-95:
// Auto: Model decides whether to call functions
public static FunctionChoiceBehavior Auto(
IEnumerable<KernelFunction>? functions = null,
bool autoInvoke = true,
FunctionChoiceBehaviorOptions? options = null)
// Required: Forces model to call functions, then stops advertising
public static FunctionChoiceBehavior Required(
IEnumerable<KernelFunction>? functions = null,
bool autoInvoke = true,
FunctionChoiceBehaviorOptions? options = null)
// None: Model describes but does not execute functions
public static FunctionChoiceBehavior None(
IEnumerable<KernelFunction>? functions = null,
bool autoInvoke = false,
FunctionChoiceBehaviorOptions? options = null)
Required behavior stopping repeated calls (from XML doc comment):
This behavior forces the model to call the provided functions.
SK connectors will invoke a requested function or multiple requested
functions if the model requests multiple ones in one request, while
handling the first request, and stop advertising the functions for
the following requests to prevent the model from repeatedly calling
the same function(s).