From 8e6fe6c8ade4b0b64add6a8ac129b463240d0c03 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 22 May 2026 17:02:12 +0000 Subject: [PATCH] fix(gemini-realtime): preserve nested turn_detection through map_openai_params After the GA remap moves session.turn_detection into session.audio.input.turn_detection, Gemini's map_openai_params only looks at top-level keys and silently drops it. Normalize the extracted turn_detection back to the top level on first session.update so the guardrail create_response:False (and any client-provided VAD settings) reach the Gemini setup. Co-authored-by: Yassin Kortam --- litellm/llms/gemini/realtime/transformation.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/litellm/llms/gemini/realtime/transformation.py b/litellm/llms/gemini/realtime/transformation.py index eb9d4ef0cbd..374e57e2fe9 100644 --- a/litellm/llms/gemini/realtime/transformation.py +++ b/litellm/llms/gemini/realtime/transformation.py @@ -267,7 +267,22 @@ class GeminiRealtimeConfig(BaseRealtimeConfig): """ session_payload = json_message.get("session") or {} if session_configuration_request is None: - # First session.update - send the setup with all configuration + # First session.update - send the setup with all configuration. + # Normalize ``turn_detection`` to the top level so map_openai_params + # picks it up whether the client used the flat beta shape or the + # GA nested shape (session.audio.input.turn_detection). Without + # this, guardrail-injected ``create_response: False`` would be + # silently dropped for GA clients because map_openai_params only + # looks at top-level keys. + extracted_turn_detection = self._extract_turn_detection(session_payload) + if ( + extracted_turn_detection is not None + and "turn_detection" not in session_payload + ): + session_payload = { + **session_payload, + "turn_detection": extracted_turn_detection, + } client_session_configuration_request = self.map_openai_params( optional_params={}, non_default_params=session_payload )