microsoft/semantic-kernel · error · KernelException
The specified {nameof(RequiredFunction)} function {this._fun
Error message
The specified {nameof(RequiredFunction)} function {this._function.FullyQualifiedName} is not available in the kernel. What it means
With RequiredFunction and auto-invocation on, ConfigureOptions checks that the specific required function exists in the kernel via TryGetFunction. If not found, KernelException is thrown. The function is about to be forced on the model, so its absence from the kernel is fatal — there is no way to satisfy the inevitable tool call.
Source
Thrown at dotnet/src/Connectors/Connectors.OpenAI/ToolCallBehavior.cs:266
internal override (IList<ChatTool>? Tools, ChatToolChoice? Choice) ConfigureOptions(Kernel? kernel)
{
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(RequiredFunction)} is not supported when no kernel is provided.");
}
// Make sure that if auto-invocation is specified, the required function can be found in the kernel.
if (autoInvoke && !kernel!.Plugins.TryGetFunction(this._function.PluginName, this._function.FunctionName, out _))
{
throw new KernelException($"The specified {nameof(RequiredFunction)} function {this._function.FullyQualifiedName} is not available in the kernel.");
}
return ([this._tool], this._choice);
}
/// <summary>Gets how many requests are part of a single interaction should include this tool in the request.</summary>
/// <remarks>
/// Unlike <see cref="EnabledFunctions"/> and <see cref="KernelFunctions"/>, this must use 1 as the maximum
/// use attempts. Otherwise, every call back to the model _requires_ it to invoke the function (as opposed
/// to allows it), which means we end up doing the same work over and over and over until the maximum is reached.
/// Thus for "requires", we must send the tool information only once.
/// </remarks>
internal override int MaximumUseAttempts => 1;
}
}
View on GitHub (pinned to c028a0c7dc)
Solutions
- Register the plugin/function in the kernel before the chat call with matching plugin and function names.
- Verify the OpenAIFunction's PluginName and FunctionName exactly match what is in kernel.Plugins.
- Use KernelFunctions behavior instead, which auto-derives functions from the kernel and avoids stale references.
Example fix
// before — required function not in kernel
var func = OpenAIFunction.Create(externalFuncMetadata); // plugin "OtherPlugin"
var behavior = ToolCallBehavior.RequireFunction(func, autoInvoke: true);
// kernel only has "MyPlugin"
// after — register the plugin the function references
kernel.Plugins.AddFromType<OtherPlugin>("OtherPlugin");
var behavior = ToolCallBehavior.RequireFunction(func, autoInvoke: true); Defensive patterns
Strategy: validation
Validate before calling
// Verify the required function is registered before the call
if (!kernel.Plugins.TryGetFunction(requiredFunc.PluginName, requiredFunc.FunctionName, out _))
{
throw new InvalidOperationException(
$"Required function {requiredFunc.PluginName}.{requiredFunc.FunctionName} is not in the kernel.");
} Try / catch
try { await chatService.GetChatMessageContentAsync(history, settings, kernel); }
catch (KernelException ex) when (ex.Message.Contains("RequiredFunction") && ex.Message.Contains("not available"))
{
// Register the missing plugin or switch to KernelFunctions behavior
kernel.Plugins.AddFromType<MissingPlugin>(requiredFunc.PluginName);
await chatService.GetChatMessageContentAsync(history, settings, kernel);
} Prevention
- Register the target plugin before constructing the RequiredFunction behavior.
- Derive the OpenAIFunction from the same kernel that will be used for the call.
When it happens
Trigger: The OpenAIFunction passed to RequireFunction references a PluginName/FunctionName that is not registered in the kernel at call time.
Common situations: Creating the RequiredFunction from a function descriptor, then rebuilding the kernel without that plugin. Plugin name mismatch between the function metadata and the kernel registration. Late-loading plugins where the registration hasn't happened yet.
Related errors
- The specified {nameof(EnabledFunctions)} function {f.FullyQu
- Auto-invocation with {nameof(RequiredFunction)} is not suppo
- Auto-invocation with {nameof(EnabledFunctions)} is not suppo
- The specified {nameof(EnabledFunctions)} function {func.Full
- Auto-invocation with {nameof(EnabledFunctions)} is not suppo
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/4d4ce820734f22ad.
Report an issue: GitHub.