BerriAI/litellm · error · ValueError
tool call not supported
Error message
tool call not supported: {tool_call} What it means
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.
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
Example fix
// before
messages=[
{"role": "assistant", "tool_calls": [{"id": "call_1", "type": "function", "function": {}}]},
]
// after
messages=[
{"role": "assistant", "tool_calls": [{"id": "call_1", "type": "function",
"function": {"name": "get_weather", "arguments": "{\"city\": \"SF\"}"}}]},
] Defensive patterns
Strategy: validation
Validate before calling
def tool_calls_are_bridge_compatible(messages) -> bool:
for msg in messages or []:
if msg.get("role") != "assistant":
continue
for tc in msg.get("tool_calls") or []:
fn = tc.get("function")
if not (isinstance(fn, dict) and fn) and not isinstance(tc.get("custom"), dict):
return False
return True Type guard
def is_supported_tool_call(tc: dict) -> bool:
return (isinstance(tc.get("function"), dict) and bool(tc.get("function"))) or isinstance(tc.get("custom"), dict) Try / catch
try:
resp = litellm.completion(model=m, messages=messages)
except ValueError as e:
if "tool call not supported" in str(e):
messages = [m for m in messages if not _has_empty_tool_calls(m)] # strip malformed entries and retry
resp = litellm.completion(model=m, messages=messages)
else:
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Chat provider: Empty parsed_chunk
- Chat provider: Invalid function argument delta
- Invalid first message. Should always start with…
- Invalid image URL
- kwarg `messages` must be an array of messages that follow…
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/4ba39c75f859f626.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/completion_extras/litellm_responses_transformation/transformation.py:348
"type": "function_call",
"call_id": tool_call["id"],
}
if "name" in function:
input_tool_call["name"] = function["name"]
if "arguments" in function:
input_tool_call["arguments"] = function["arguments"]
input_items.append(input_tool_call)
elif isinstance(custom, dict):
input_items.append(
ResponseCustomToolCallParam(
type="custom_tool_call",
call_id=tool_call["id"],
name=custom.get("name", ""),
input=custom.get("input", ""),
)
)
else:
raise ValueError(f"tool call not supported: {tool_call}")
elif content is not None:
if role == "assistant":
for r_item in _get_reasoning_items(msg):
input_items.append(_reasoning_item_to_response_input(r_item))
input_items.append(
{
"type": "message",
"role": role,
"content": self._convert_content_to_responses_format(content, cast(str, role)),
}
)
return input_items, instructions
def _map_optional_params_to_responses_api_request(
self,
optional_params: dict,
responses_api_request: "ResponsesAPIOptionalRequestParams",View on GitHub (pinned to 77b7c6c40c)