{"record":{"id":"a2608cf91fb04154","repo":"microsoft/semantic-kernel","slug":"the-specified-nameof-enabledfunctions-function-a2608c","errorCode":null,"errorMessage":"The specified {nameof(EnabledFunctions)} function {f.FullyQualifiedName} is not available in the kernel.","messagePattern":"The specified (.+?) function (.+?) is not available in the kernel\\.","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.OpenAI/ToolCallBehavior.cs","lineNumber":220,"sourceCode":"                // on the consumers behalf: if they specify auto-invocation with any functions, they must\n                // specify the kernel and the kernel must contain those functions.\n                if (autoInvoke && kernel is null)\n                {\n                    throw new KernelException($\"Auto-invocation with {nameof(EnabledFunctions)} is not supported when no kernel is provided.\");\n                }\n\n                choice = ChatToolChoice.CreateAutoChoice();\n                tools = [];\n                for (int i = 0; i < openAIFunctions.Length; i++)\n                {\n                    // Make sure that if auto-invocation is specified, every enabled function can be found in the kernel.\n                    if (autoInvoke)\n                    {\n                        Debug.Assert(kernel is not null);\n                        OpenAIFunction f = openAIFunctions[i];\n                        if (!kernel!.Plugins.TryGetFunction(f.PluginName, f.FunctionName, out _))\n                        {\n                            throw new KernelException($\"The specified {nameof(EnabledFunctions)} function {f.FullyQualifiedName} is not available in the kernel.\");\n                        }\n                    }\n\n                    // Add the function.\n                    tools.Add(functions[i]);\n                }\n            }\n\n            return (tools, choice);\n        }\n    }\n\n    /// <summary>Represents a <see cref=\"ToolCallBehavior\"/> that requests the model use a specific function.</summary>\n    internal sealed class RequiredFunction : ToolCallBehavior\n    {\n        private readonly OpenAIFunction _function;\n        private readonly ChatTool _tool;\n        private readonly ChatToolChoice _choice;","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.OpenAI/ToolCallBehavior.cs#L202-L238","documentation":"With EnabledFunctions and auto-invocation on, ConfigureOptions iterates each enabled function and calls kernel.Plugins.TryGetFunction(pluginName, functionName). If any function is not registered in the kernel's plugins, KernelException is thrown. The function metadata was advertised to the model but cannot be found for execution.","triggerScenarios":"Registering ToolCallBehavior.EnabledFunctions with a list of OpenAIFunction objects whose PluginName/FunctionName don't match any function actually loaded into the kernel passed to the chat call.","commonSituations":"Building the OpenAIFunction list from one plugin instance but registering a different plugin (or a renamed one) in the kernel. Function name casing mismatch. Forgetting to call kernel.Plugins.Add(...) before invoking. Deserializing function metadata that references a plugin not yet loaded.","solutions":["Ensure kernel.Plugins contains a plugin with the exact name and function name referenced by each OpenAIFunction.","Verify PluginName and FunctionName casing matches exactly — TryGetFunction is case-sensitive.","Register the plugin before the chat call: kernel.Plugins.AddFromType<MyPlugin>(\"MyPlugin\").","Print kernel.Plugins.GetFunctionsMetadata() to confirm which functions are actually available."],"exampleFix":"// before — function references a plugin not in the kernel\nvar functions = kernel.Plugins.GetFunctionsMetadata()\n    .Where(f => f.PluginName == \"MissingPlugin\").Select(OpenAIFunction.Create);\nvar behavior = ToolCallBehavior.EnableFunctions(functions, autoInvoke: true);\n\n// after — register the plugin first, then build the function list from it\nkernel.Plugins.AddFromType<WeatherPlugin>(\"WeatherPlugin\");\nvar functions = kernel.Plugins[\"WeatherPlugin\"].Select(f => OpenAIFunction.Create(f));\nvar behavior = ToolCallBehavior.EnableFunctions(functions, autoInvoke: true);","handlingStrategy":"validation","validationCode":"// Verify all enabled functions exist in the kernel before the chat call\nforeach (var f in openAIFunctions)\n{\n    if (!kernel.Plugins.TryGetFunction(f.PluginName, f.FunctionName, out _))\n    {\n        throw new InvalidOperationException(\n            $\"Function {f.PluginName}.{f.FunctionName} is not registered in the kernel.\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try { await chatService.GetChatMessageContentAsync(history, settings, kernel); }\ncatch (KernelException ex) when (ex.Message.Contains(\"not available in the kernel\"))\n{\n    // Log available functions for debugging\n    var available = string.Join(\", \", kernel.Plugins.GetFunctionsMetadata().Select(f => $\"{f.PluginName}.{f.FunctionName}\"));\n    logger.LogError(\"Function not in kernel. Available: {Functions}\", available);\n    throw;\n}","preventionTips":["Build the OpenAIFunction list directly from kernel.Plugins to guarantee name consistency.","Register all plugins before creating the behavior, not after.","Use KernelFunctions (ToolCallBehavior.AutoInvokeKernelFunctions) to avoid manual function-list drift."],"tags":["tool-calling","plugin","kernel","function-registration"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}