test(gemini realtime): exercise toolCall → function_call_output name round-trip

Update test_gemini_realtime_function_call_output_transformation to pre-load
the call_id → name mapping by transforming a Gemini toolCall first, then
assert that the resulting Gemini toolResponse functionResponses entry
carries the function name. This pins the production round-trip rather
than the degenerate 'name missing' branch.
This commit is contained in:
mateo-berri 2026-05-22 20:47:48 +00:00
parent 36f6d84c22
commit 24b8e17a4b
No known key found for this signature in database

View file

@ -445,9 +445,44 @@ def test_gemini_requires_session_configuration_feature_flag(monkeypatch):
def test_gemini_realtime_function_call_output_transformation():
"""Test transformation of OpenAI function_call_output to Gemini toolResponse format."""
"""Test transformation of OpenAI function_call_output to Gemini toolResponse format.
Exercises the full production round-trip: a Gemini toolCall arrives first
and populates the call_id -> name mapping, then the OpenAI
function_call_output is transformed and must carry the function name back
to Gemini in functionResponses.
"""
config = GeminiRealtimeConfig()
# Receive a toolCall from Gemini first to populate the call_id -> name mapping.
logging_obj = MagicMock()
logging_obj.litellm_trace_id = "trace_func_output"
config.transform_realtime_response(
json.dumps({
"toolCall": {
"functionCalls": [
{
"id": "call_123",
"name": "get_weather",
"args": {"location": "San Francisco"},
}
]
}
}),
"gemini-2.5-flash",
logging_obj,
realtime_response_transform_input={
"session_configuration_request": None,
"current_output_item_id": None,
"current_response_id": None,
"current_conversation_id": None,
"current_delta_chunks": [],
"current_item_chunks": [],
"current_delta_type": None,
},
)
assert config._tool_call_id_to_name.get("call_123") == "get_weather"
# OpenAI format function call output
function_output = {
"type": "conversation.item.create",
@ -479,6 +514,7 @@ def test_gemini_realtime_function_call_output_transformation():
func_response = tool_response["functionResponses"][0]
assert func_response["id"] == "call_123"
assert func_response["name"] == "get_weather"
assert "response" in func_response
assert func_response["response"]["temperature"] == 72
assert func_response["response"]["conditions"] == "sunny"