microsoft/semantic-kernel · error · KernelException

The specified {nameof(EnabledFunctions)} function {func.Full

Error message

The specified {nameof(EnabledFunctions)} function {func.FullyQualifiedName} is not available in the kernel.

What it means

Thrown by EnabledFunctions.ConfigureGeminiRequest when auto-invocation is enabled and one of the functions declared in the behavior's list cannot be found in kernel.Plugins by (PluginName, FunctionName). The connector pre-validates that every advertised function is actually resolvable so it can execute it when the model calls back.

Source

Thrown at dotnet/src/Connectors/Connectors.Google/GeminiToolCallBehavior.cs:186

            // 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.");
            }

            foreach (var func in this._functions)
            {
                // Make sure that if auto-invocation is specified, every enabled function can be found in the kernel.
                if (autoInvoke)
                {
                    if (!kernel!.Plugins.TryGetFunction(func.PluginName, func.FunctionName, out _))
                    {
                        throw new KernelException(
                            $"The specified {nameof(EnabledFunctions)} function {func.FullyQualifiedName} is not available in the kernel.");
                    }
                }

                // Add the function.
                request.AddFunction(func);
            }
        }
    }
}

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Ensure every function in the EnabledFunctions list is registered in kernel.Plugins under the same plugin and function name.
  2. Verify func.PluginName and func.FunctionName match the registered metadata (check FullyQualifiedName in the error message).
  3. Add the plugin to the kernel before building/using the tool-call behavior, or build the behavior from kernel.Plugins.GetFunctionsMetadata().

Example fix

// before (names mismatch)
kernel.Plugins.AddFromType<MyPlugin>("WeatherPlugin");
var fn = kernel.Plugins["WeatherPlugin"]["GetWeather"].Metadata.ToGeminiFunction();
// behavior was built with a function whose PluginName is "Weather" -> throws

// after (consistent names)
var functions = kernel.Plugins.GetFunctionsMetadata().Select(m => m.ToGeminiFunction());
var behavior = GeminiToolCallBehavior.EnabledFunctions(autoInvoke: true, functions);
Defensive patterns

Strategy: validation

Validate before calling

static void EnsureFunctionsRegistered(Kernel kernel, IEnumerable<GeminiFunction> fns)
{
    foreach (var f in fns)
        if (!kernel.Plugins.TryGetFunction(f.PluginName, f.FunctionName, out _))
            throw new InvalidOperationException($"Function {f.FullyQualifiedName} missing from kernel.Plugins.");
}

Type guard

static bool AllFunctionsRegistered(Kernel kernel, IEnumerable<GeminiFunction> fns)
    => fns.All(f => kernel.Plugins.TryGetFunction(f.PluginName, f.FunctionName, out _));

Try / catch

try { await kernel.InvokePromptAsync(prompt, new(settings)); }
catch (KernelException ex) when (ex.Message.Contains("not available in the kernel"))
{ logger.LogError(ex, "Register the advertised functions in the kernel or fix the name."); throw; }

Prevention

When it happens

Trigger: Listing a GeminiFunction in EnabledFunctions whose plugin/function name does not match any function registered in kernel.Plugins; typo in the plugin or function name; registering the plugin after constructing the behavior; passing a different kernel than the one that owns the plugins.

Common situations: Mismatch between the plugin name used to build the GeminiFunction and the plugin name used at Kernel.Plugins.Add; renaming a function/plugin without updating the behavior; enabling autoInvoke for functions defined in a plugin that was never added to the kernel.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/784e10c18368918c. Report an issue: GitHub.