{"record":{"id":"4ba39c75f859f626","repo":"BerriAI/litellm","slug":"tool-call-not-supported-tool-call","errorCode":null,"errorMessage":"tool call not supported: {tool_call}","messagePattern":"tool call not supported: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/completion_extras/litellm_responses_transformation/transformation.py","lineNumber":348,"sourceCode":"                            \"type\": \"function_call\",\n                            \"call_id\": tool_call[\"id\"],\n                        }\n                        if \"name\" in function:\n                            input_tool_call[\"name\"] = function[\"name\"]\n                        if \"arguments\" in function:\n                            input_tool_call[\"arguments\"] = function[\"arguments\"]\n                        input_items.append(input_tool_call)\n                    elif isinstance(custom, dict):\n                        input_items.append(\n                            ResponseCustomToolCallParam(\n                                type=\"custom_tool_call\",\n                                call_id=tool_call[\"id\"],\n                                name=custom.get(\"name\", \"\"),\n                                input=custom.get(\"input\", \"\"),\n                            )\n                        )\n                    else:\n                        raise ValueError(f\"tool call not supported: {tool_call}\")\n            elif content is not None:\n                if role == \"assistant\":\n                    for r_item in _get_reasoning_items(msg):\n                        input_items.append(_reasoning_item_to_response_input(r_item))\n                input_items.append(\n                    {\n                        \"type\": \"message\",\n                        \"role\": role,\n                        \"content\": self._convert_content_to_responses_format(content, cast(str, role)),\n                    }\n                )\n\n        return input_items, instructions\n\n    def _map_optional_params_to_responses_api_request(\n        self,\n        optional_params: dict,\n        responses_api_request: \"ResponsesAPIOptionalRequestParams\",","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/completion_extras/litellm_responses_transformation/transformation.py#L330-L366","documentation":"When the bridge converts prior chat turns into Responses API input items, each assistant tool_calls entry must carry either a non-empty 'function' dict (with name/arguments) or a 'custom' dict. An entry that has neither — missing function key, function=None, or an empty function dict with no custom block — cannot be represented as function_call or custom_tool_call and is rejected. The message includes the offending tool_call for inspection.","triggerScenarios":"messages containing {\"role\":\"assistant\",\"tool_calls\":[{\"id\":\"1\"}]} (no function); tool_calls entries with function={} after JSON round-tripping stripped fields; replaying tool calls captured from another provider's schema (e.g. Anthropic content blocks) without converting to OpenAI tool_call shape; LLM-generated tool call objects missing the function payload.","commonSituations":"Agent loops persisting and replaying conversation history where empty/aborted tool calls sneak in; data pipelines normalizing messages that drop function fields; multi-provider setups feeding foreign tool-call formats into litellm.","solutions":["Ensure every assistant tool_calls entry has id plus a non-empty function dict with name and arguments (arguments as a JSON string)","Filter or repair malformed entries before sending: drop tool_calls whose function dict is empty and the matching tool response","Convert non-OpenAI tool-call formats to {id, type:'function', function:{name, arguments}} before passing messages","If the entry was meant for a custom tool, provide the 'custom' dict with name and input keys"],"exampleFix":"// before\nmessages=[\n  {\"role\": \"assistant\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {}}]},\n]\n\n// after\nmessages=[\n  {\"role\": \"assistant\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\",\n     \"function\": {\"name\": \"get_weather\", \"arguments\": \"{\\\"city\\\": \\\"SF\\\"}\"}}]},\n]","handlingStrategy":"validation","validationCode":"def tool_calls_are_bridge_compatible(messages) -> bool:\n    for msg in messages or []:\n        if msg.get(\"role\") != \"assistant\":\n            continue\n        for tc in msg.get(\"tool_calls\") or []:\n            fn = tc.get(\"function\")\n            if not (isinstance(fn, dict) and fn) and not isinstance(tc.get(\"custom\"), dict):\n                return False\n    return True","typeGuard":"def is_supported_tool_call(tc: dict) -> bool:\n    return (isinstance(tc.get(\"function\"), dict) and bool(tc.get(\"function\"))) or isinstance(tc.get(\"custom\"), dict)","tryCatchPattern":"try:\n    resp = litellm.completion(model=m, messages=messages)\nexcept ValueError as e:\n    if \"tool call not supported\" in str(e):\n        messages = [m for m in messages if not _has_empty_tool_calls(m)]  # strip malformed entries and retry\n        resp = litellm.completion(model=m, messages=messages)\n    else:\n        raise","preventionTips":["Validate replayed conversation history: every assistant tool_call needs id + non-empty function{name, arguments}","Drop aborted/empty tool calls (and their orphaned tool responses) before resending","Convert foreign tool-call schemas (Anthropic etc.) to OpenAI shape at ingestion","Never let LLM- or user-authored dicts straight into messages without a shape check"],"tags":["tool-calling","messages","responses-api","validation"],"backgroundTag":"unsupported-tool-call-format","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}