Gemini tool translate maps empty arguments="" to args={"type":"object"} instead of {}
Description
Gemini/Vertex tool-call history translation invents args={"type": "object"} when a prior tool call has empty function.arguments ("" or missing).
Zero-arg tools often arrive with arguments="". Anthropic/Bedrock correctly map that to input={}. Gemini maps empty string to a schema stub wrongly injected as runtime arguments.
Environment
litellm==1.102.1- Python 3.13
Minimal repro
from litellm.litellm_core_utils.prompt_templates.factory import (
convert_to_gemini_tool_call_invoke,
convert_to_anthropic_tool_invoke,
)
msg = {
"role": "assistant",
"content": None,
"tool_calls": [
{
"id": "call_1",
"type": "function",
"function": {"name": "list_directory", "arguments": ""},
},
{
"id": "call_2",
"type": "function",
"function": {"name": "ping", "arguments": "{}"},
},
],
}
gemini_parts = convert_to_gemini_tool_call_invoke(msg)
print(gemini_parts[0]["function_call"]["args"]) # ACTUAL: {'type': 'object'} EXPECTED: {}
print(gemini_parts[1]["function_call"]["args"]) # {} (ok)
anth = convert_to_anthropic_tool_invoke(msg["tool_calls"])
print(anth[0]["input"]) # {} (ok)Expected
Empty/missing arguments → {} for Gemini, same as Anthropic/Bedrock.
Actual
arguments="" → Gemini args={'type': 'object'}; arguments="{}" is fine.
Root cause (pointer)
litellm/litellm_core_utils/prompt_templates/factory.py — _gemini_tool_call_invoke_helper / convert_to_gemini_tool_call_invoke.
Suggested fix direction
Empty/missing arguments → {}. Do not hard-code {"type":"object"}.
Impact
Multi-turn Gemini/Vertex agent sessions that replay prior zero-arg tool calls send bogus parameters (list_directory, ping, …), causing incorrect tool execution or provider errors.
Source: BerriAI/litellm