{"record":{"id":"6fb2190cb49b4102","repo":"microsoft/semantic-kernel","slug":"multiple-definitions-found-for-spec-id-please","errorCode":null,"errorMessage":"Multiple definitions found for `{spec.id}`. Please remove duplicates.","messagePattern":"Multiple definitions found for `(.+?)`\\. Please remove duplicates\\.","errorType":"validation","errorClass":"AgentInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/azure_ai/azure_ai_agent.py","lineNumber":194,"sourceCode":"def _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.\")\n\n    try:\n        parsed_spec = json.loads(raw_spec) if isinstance(raw_spec, str) else raw_spec\n    except json.JSONDecodeError as e:","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/azure_ai/azure_ai_agent.py#L176-L212","documentation":"Raised when the declarative function-tool builder resolves more than one function for a single pluginName.functionName id. The lookup must be unambiguous to map one tool to one kernel function.","triggerScenarios":"Two plugins or two functions share the same fully-qualified name, so get_list_of_function_metadata_filters returns >1 entry.","commonSituations":"Same plugin registered twice under the same name; method overloaded with duplicate @kernel_function names; copy-paste plugin definitions; merging specs that both register 'MyPlugin.MyFunc'.","solutions":["Remove the duplicate registration so only one function matches the id.","Rename one of the conflicting plugins or functions to disambiguate.","Audit kernel.get_list_of_function_metadata_filters({}) output for repeated fully_qualified_name values."],"exampleFix":"// before\nkernel.add_plugin(PluginA(), \"Shared\")\nkernel.add_plugin(PluginB(), \"Shared\")  # both define Func\n# spec id: Shared.Func -> 2 matches\n\n// after\nkernel.add_plugin(PluginA(), \"Shared\")\nkernel.add_plugin(PluginB(), \"SharedB\")\n# spec id: Shared.Func or SharedB.Func","handlingStrategy":"validation","validationCode":"def assert_unique_fqns(kernel) -> None:\n    fqns = [f.fully_qualified_name for f in kernel.get_list_of_function_metadata_filters({})}\n    dupes = {f for f in fqns if fqns.count(f) > 1}\n    if dupes:\n        raise ValueError(f\"Duplicate fully_qualified_name(s): {sorted(dupes)}\")","typeGuard":"def no_duplicate_fqns(kernel) -> bool:\n    fqns = [f.fully_qualified_name for f in kernel.get_list_of_function_metadata_filters({})]\n    return len(fqns) == len(set(fqns))","tryCatchPattern":null,"preventionTips":["Run a uniqueness check on fully_qualified_name after all plugins are registered.","Avoid registering the same plugin name twice; namespace plugins distinctly."],"tags":["azure-ai-agent","declarative-spec","function-tool","duplicates"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}