{"record":{"id":"8b8cc2c9438c9cca","repo":"mlflow/mlflow","slug":"unknown-tool-type-tool-type","errorCode":null,"errorMessage":"Unknown tool type: {tool_type}","messagePattern":"Unknown tool type: (.+?)","errorType":"exception","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/openai/utils/chat_schema.py","lineNumber":127,"sourceCode":"                # Responses API style\n                definition = {k: v for k, v in tool.items() if k != \"type\"}\n                parsed_tools.append(\n                    ChatTool(\n                        type=\"function\",\n                        function=FunctionToolDefinition(**definition),\n                    )\n                )\n        elif tool_type in _RESPONSE_API_BUILT_IN_TOOLS:\n            parsed_tools.append(\n                ChatTool(\n                    type=\"function\",\n                    function=FunctionToolDefinition(\n                        name=tool_type,\n                    ),\n                )\n            )\n        else:\n            raise MlflowException(f\"Unknown tool type: {tool_type}\")\n\n    return parsed_tools\n\n\ndef _parse_model(output: Any) -> str | None:\n    \"\"\"\n    Parse model information from OpenAI response objects.\n\n    Args:\n        output: The response object from OpenAI API calls\n\n    Returns:\n        The model name.\n    \"\"\"\n    if output is None:\n        return None\n\n    # Handle OpenAI ChatCompletion API response","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/openai/utils/chat_schema.py#L109-L145","documentation":"When converting OpenAI chat tool definitions to MLflow span chat attributes, each tool's 'type' field must be a recognized kind (e.g., 'function'). Any other type string has no defined mapping, so _parse_tools raises this MlflowException.","triggerScenarios":"Calling mlflow.openai.utils.chat_schema.set_span_chat_attributes() (which calls _parse_tools) with response/tool payload whose tools include a type outside the supported set — e.g., a custom tool type, a newer OpenAI tool type not yet handled, or a malformed tools list where 'type' is arbitrary.","commonSituations":"Tracing newer OpenAI tool types (e.g., custom/hosted tools) that this MLflow version doesn't map yet; passing hand-built tool dicts with misspelled or invented 'type' values; proxying non-OpenAI APIs that emit their own tool types.","solutions":["Upgrade MLflow to a version that supports the new tool type","Normalize tool definitions to supported types (e.g., convert to {'type': 'function', 'function': {...}}) before calling set_span_chat_attributes","Skip or filter unsupported tools from the payload before setting span attributes"],"exampleFix":"// before\nspan_attrs_tools = [{\"type\": \"custom_tool\", ...}]\nset_span_chat_attributes(span, output)  # raises\n\n// after\ntools = [{\"type\": \"function\", \"function\": {\"name\": \"get_weather\", ...}}]\nset_span_chat_attributes(span, {**output, \"tools\": tools})","handlingStrategy":"validation","validationCode":"SUPPORTED_TOOL_TYPES = {\"function\"}\ndef validate_tools(tools):\n    for t in tools or []:\n        if t.get(\"type\") not in SUPPORTED_TOOL_TYPES:\n            raise ValueError(f\"Tool type {t.get('type')!r} not supported by set_span_chat_attributes\")","typeGuard":"def is_supported_tool(tool: dict) -> bool:\n    return isinstance(tool, dict) and tool.get(\"type\") == \"function\"","tryCatchPattern":"from mlflow.exceptions import MlflowException\ntry:\n    set_span_chat_attributes(span, output)\nexcept MlflowException as e:\n    if \"Unknown tool type\" in str(e):\n        output[\"tools\"] = [t for t in output.get(\"tools\", []) if t.get(\"type\") == \"function\"]\n        set_span_chat_attributes(span, output)\n    else:\n        raise","preventionTips":["Filter tool payloads to supported types before setting span attributes","Keep MLflow updated to gain mappings for new OpenAI tool types","Normalize non-OpenAI tool schemas to {'type': 'function', ...} before tracing"],"tags":["mlflow","openai","tracing","tools","schema"],"backgroundTag":"unknown-tool-type","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}