{"record":{"id":"91aec847ef9728a4","repo":"microsoft/semantic-kernel","slug":"function-spec-id-not-found-in-kernel","errorCode":null,"errorMessage":"Function `{spec.id}` not found in kernel.","messagePattern":"Function `(.+?)` not found in kernel\\.","errorType":"validation","errorClass":"AgentInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/azure_ai/azure_ai_agent.py","lineNumber":190,"sourceCode":"    return FileSearchTool(vector_store_ids=vector_store_ids)\n\n\n@_register_tool(\"function\")\ndef _function(spec: ToolSpec, kernel: \"Kernel\") -> ToolDefinition:\n    def parse_fqn(fqn: str) -> tuple[str, str]:\n        parts = fqn.split(\".\")\n        if len(parts) != 2:\n            raise AgentInitializationException(f\"Function `{fqn}` must be in the form `pluginName.functionName`.\")\n        return parts[0], parts[1]\n\n    if not spec.id:\n        raise AgentInitializationException(\"Function ID is required for function tools.\")\n    plugin_name, function_name = parse_fqn(spec.id)\n    funcs = kernel.get_list_of_function_metadata_filters({\"included_functions\": f\"{plugin_name}-{function_name}\"})\n\n    match len(funcs):\n        case 0:\n            raise AgentInitializationException(f\"Function `{spec.id}` not found in kernel.\")\n        case 1:\n            return kernel_function_metadata_to_function_call_format(funcs[0])  # type: ignore[return-value]\n        case _:\n            raise AgentInitializationException(f\"Multiple definitions found for `{spec.id}`. Please remove duplicates.\")\n\n\n@_register_tool(\"openapi\")\ndef _openapi(spec: ToolSpec) -> OpenApiTool:\n    opts = spec.options or {}\n\n    if not spec.id:\n        raise AgentInitializationException(\"OpenAPI tool requires a non-empty 'id' (used as name).\")\n    if not spec.description:\n        raise AgentInitializationException(f\"OpenAPI tool '{spec.id}' requires a 'description'.\")\n\n    raw_spec = opts.get(\"specification\")\n    if not raw_spec:\n        raise AgentInitializationException(f\"OpenAPI tool '{spec.id}' is missing required 'specification' field.\")","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/azure_ai/azure_ai_agent.py#L172-L208","documentation":"Raised when the declarative function-tool builder looks up pluginName.functionName via kernel.get_list_of_function_metadata_filters and gets zero matches. The id resolves to no registered kernel function.","triggerScenarios":"Function tool id references a plugin/function not registered on the Kernel passed to the agent factory, or the name uses wrong casing/separator.","commonSituations":"Plugin registered under a different name; function not decorated with @kernel_function; Kernel passed to the factory is a fresh instance without plugins; spec built against a different environment.","solutions":["Register the referenced plugin on the Kernel before building the agent: kernel.add_plugin(MyPlugin(), \"MyPlugin\").","Verify the function is decorated with @kernel_function so its metadata is discoverable.","Match id casing and separator exactly to the kernel's fully_qualified_name.","Inspect kernel.get_list_of_function_metadata_filters({'included_functions': 'PluginName-FunctionName'}) to confirm discoverability."],"exampleFix":"// before\nkernel = Kernel()  # no plugins added\ntools:\n  - type: function\n    id: Search.Lookup\n\n// after\nkernel = Kernel()\nkernel.add_plugin(SearchPlugin(), \"Search\")\ntools:\n  - type: function\n    id: Search.Lookup","handlingStrategy":"validation","validationCode":"def ensure_function_exists(kernel, plugin: str, func: str) -> None:\n    found = kernel.get_list_of_function_metadata_filters({\"included_functions\": f\"{plugin}-{func}\"})\n    if len(found) != 1:\n        raise ValueError(f\"{plugin}.{func} not found or ambiguous: {len(found)} matches\")","typeGuard":"def function_resolvable(kernel, plugin: str, func: str) -> bool:\n    found = kernel.get_list_of_function_metadata_filters({\"included_functions\": f\"{plugin}-{func}\"})\n    return len(found) == 1","tryCatchPattern":null,"preventionTips":["Register all plugins on the Kernel before building the declarative agent.","Confirm each @kernel_function is decorated and the plugin name matches the spec id prefix."],"tags":["azure-ai-agent","declarative-spec","function-tool","kernel","registration"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}