From 24b8e17a4be169b900b6fd290397786d8499c487 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Fri, 22 May 2026 20:47:48 +0000 Subject: [PATCH] =?UTF-8?q?test(gemini=20realtime):=20exercise=20toolCall?= =?UTF-8?q?=20=E2=86=92=20function=5Fcall=5Foutput=20name=20round-trip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../test_gemini_realtime_transformation.py | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/tests/test_litellm/llms/gemini/realtime/test_gemini_realtime_transformation.py b/tests/test_litellm/llms/gemini/realtime/test_gemini_realtime_transformation.py index 0e619a50872..409e0734ddc 100644 --- a/tests/test_litellm/llms/gemini/realtime/test_gemini_realtime_transformation.py +++ b/tests/test_litellm/llms/gemini/realtime/test_gemini_realtime_transformation.py @@ -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"