{"record":{"id":"3daf68feb73a5113","repo":"BerriAI/litellm","slug":"top-level-function-names-conflict-with-flattened-n","errorCode":null,"errorMessage":"Top-level function names conflict with flattened namespace tools: {conflicting_tool_names}","messagePattern":"Top-level function names conflict with flattened namespace tools: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/responses/litellm_completion_transformation/transformation.py","lineNumber":1476,"sourceCode":"        return (flat_tool,) if flat_tool is not None else ()\n\n    @staticmethod\n    def _validate_namespace_name_collisions(tools: ResponseTools) -> None:\n        top_level_function_names: Final = frozenset(\n            str(tool.get(\"name\") or \"\") for tool in tools or () if tool.get(\"type\") == \"function\"\n        )\n        flattened_namespace_names: Final = frozenset(\n            f\"{(tool.get('name') or '')!s}__{(namespace_tool.get('name') or '')!s}\"\n            for tool in tools or ()\n            if tool.get(\"type\") == \"namespace\"\n            for namespace_tools in (tool.get(\"tools\"),)\n            if isinstance(namespace_tools, Sequence) and not isinstance(namespace_tools, (str, bytes))\n            for namespace_tool in namespace_tools\n            if isinstance(namespace_tool, Mapping) and namespace_tool.get(\"type\") == \"function\"\n        )\n        conflicting_tool_names: Final = top_level_function_names & flattened_namespace_names\n        if conflicting_tool_names:\n            raise ValueError(\n                \"Top-level function names conflict with flattened namespace tools: \"\n                + \", \".join(sorted(conflicting_tool_names))\n            )\n\n    @staticmethod\n    def transform_responses_api_tools_to_chat_completion_tools(\n        tools: list[FunctionToolParam | OpenAIMcpServerTool] | None,\n    ) -> tuple[\n        list[ChatCompletionToolParam | OpenAIMcpServerTool],\n        OpenAIWebSearchOptions | None,\n    ]:\n        \"\"\"\n        Transform a Responses API tools into a Chat Completion tools\n        \"\"\"\n        if tools is None:\n            return [], None\n        LiteLLMCompletionResponsesConfig._validate_namespace_name_collisions(tools)\n        chat_completion_tools: Final[list[ChatCompletionToolParam | OpenAIMcpServerTool]] = []","sourceCodeStart":1458,"sourceCodeEnd":1494,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/responses/litellm_completion_transformation/transformation.py#L1458-L1494","documentation":"Collision guard when flattening Responses-API namespace tools: one or more generated '<tool>__<subtool>' flattened names are identical to a top-level function tool's name, which would make the tool namespace ambiguous; the conflicting names are listed in the message.","triggerScenarios":"Thrown at litellm/responses/litellm_completion_transformation/transformation.py:1476 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename conflicting tools so top-level function names don't clash with flattened namespace tool names."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}