microsoft/semantic-kernel · error · KernelException
Auto-invocation with {nameof(EnabledFunctions)} is not suppo
Error message
Auto-invocation with {nameof(EnabledFunctions)} is not supported when no kernel is provided. What it means
EnabledFunctions tool-call behavior is configured with auto-invocation enabled (MaximumAutoInvokeAttempts > 0). When ConfigureOptions runs, if there are enabled functions but the kernel argument is null, it throws immediately. The connector refuses to advertise functions to the model that it cannot execute, since the model may call them and the connector would have no kernel to dispatch through.
Source
Thrown at dotnet/src/Connectors/Connectors.OpenAI/ToolCallBehavior.cs:206
ChatToolChoice? choice = null;
List<ChatTool>? tools = null;
OpenAIFunction[] openAIFunctions = this._openAIFunctions;
ChatTool[] functions = this._functions;
Debug.Assert(openAIFunctions.Length == functions.Length);
if (openAIFunctions.Length > 0)
{
bool autoInvoke = base.MaximumAutoInvokeAttempts > 0;
// If auto-invocation is specified, we need a kernel to be able to invoke the functions.
// Lack of a kernel is fatal: we don't want to tell the model we can handle the functions
// and then fail to do so, so we fail before we get to that point. This is an error
// on the consumers behalf: if they specify auto-invocation with any functions, they must
// specify the kernel and the kernel must contain those functions.
if (autoInvoke && kernel is null)
{
throw new KernelException($"Auto-invocation with {nameof(EnabledFunctions)} is not supported when no kernel is provided.");
}
choice = ChatToolChoice.CreateAutoChoice();
tools = [];
for (int i = 0; i < openAIFunctions.Length; i++)
{
// Make sure that if auto-invocation is specified, every enabled function can be found in the kernel.
if (autoInvoke)
{
Debug.Assert(kernel is not null);
OpenAIFunction f = openAIFunctions[i];
if (!kernel!.Plugins.TryGetFunction(f.PluginName, f.FunctionName, out _))
{
throw new KernelException($"The specified {nameof(EnabledFunctions)} function {f.FullyQualifiedName} is not available in the kernel.");
}
}
// Add the function.View on GitHub (pinned to c028a0c7dc)
Solutions
- Pass a non-null Kernel to the chat completion call — the kernel must contain the plugins with the enabled functions.
- If you don't need auto-invocation, create the behavior with autoInvoke: false so no kernel is required.
- If you are calling the OpenAI SDK directly without Semantic Kernel, use a non-auto-invoking behavior or none at all.
Example fix
// before — auto-invoke enabled but no kernel var behavior = ToolCallBehavior.EnableFunctions(functions, autoInvoke: true); await chatService.GetChatMessageContentAsync(history, settings); // no kernel! // after — pass the kernel await chatService.GetChatMessageContentAsync(history, settings, kernel: myKernel); // or disable auto-invoke if you handle tool calls manually var behavior = ToolCallBehavior.EnableFunctions(functions, autoInvoke: false);
Defensive patterns
Strategy: validation
Validate before calling
// Before calling chat completion, verify the invariant:
// auto-invoking behaviors require a kernel
if (behavior.MaximumAutoInvokeAttempts > 0 && kernel is null)
{
throw new InvalidOperationException(
"Auto-invocation requires a non-null Kernel. Pass the kernel or disable autoInvoke.");
} Try / catch
try { await chatService.GetChatMessageContentAsync(history, settings, kernel); }
catch (KernelException ex) when (ex.Message.Contains("no kernel is provided"))
{
// Either pass a kernel or disable auto-invoke before retrying
throw new InvalidOperationException("Pass a Kernel to enable auto-invocation.", ex);
} Prevention
- Always pass the kernel to chat calls when using EnableFunctions with autoInvoke.
- Centralize behavior creation in a factory that also validates kernel availability.
- Document that autoInvoke=true requires the kernel in your team's integration guide.
When it happens
Trigger: Creating ToolCallBehavior.EnabledFunctions(functions, autoInvoke: true) and then calling the chat completion API without passing a Kernel instance (kernel is null). This happens when invoking the underlying OpenAI client directly or through a code path that omits the kernel.
Common situations: Calling chatPrompt execution methods that don't thread the kernel through. Using KernelFunction-less invocation patterns. Accidentally passing null kernel in a custom orchestration wrapper.
Related errors
- Auto-invocation with {nameof(EnabledFunctions)} is not suppo
- The specified {nameof(EnabledFunctions)} function {func.Full
- Auto-invocation with {nameof(RequiredFunction)} is not suppo
- AZURE_FOUNDRY_PROJECT_ENDPOINT is not set.
- AZURE_OPENAI_ENDPOINT is not set.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/575b0ff063db555f.
Report an issue: GitHub.