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 <yassin@berri.ai>
This commit is contained in:
Cursor Agent 2026-05-22 17:02:12 +00:00
parent 24af92663d
commit 8e6fe6c8ad
No known key found for this signature in database

View file

@ -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
)