Skip to content

Commit 877a7c3

Browse files
authored
Support model_version param for turn detection in realtime agents sdk (#2450)
1 parent 3a5e6fe commit 877a7c3

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/agents/realtime/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ class RealtimeTurnDetectionConfig(TypedDict):
100100
idle_timeout_ms: NotRequired[int]
101101
"""Threshold for server-vad to trigger a response if the user is idle for this duration."""
102102

103+
model_version: NotRequired[str]
104+
"""Optional backend-specific VAD model identifier."""
105+
103106

104107
class RealtimeAudioInputConfig(TypedDict, total=False):
105108
"""Configuration for audio input in realtime sessions."""

src/agents/realtime/openai_realtime.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,7 @@ def _normalize_turn_detection_config(config: object) -> object:
998998
"prefixPaddingMs": "prefix_padding_ms",
999999
"silenceDurationMs": "silence_duration_ms",
10001000
"idleTimeoutMs": "idle_timeout_ms",
1001+
"modelVersion": "model_version",
10011002
}
10021003
for camel_key, snake_key in key_map.items():
10031004
if camel_key in normalized and snake_key not in normalized:

tests/realtime/test_openai_realtime.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ def test_session_config_respects_audio_block_and_output_modalities(self, model):
821821
"type": "server_vad",
822822
"createResponse": True,
823823
"silenceDurationMs": 450,
824+
"modelVersion": "default",
824825
},
825826
},
826827
"output": {
@@ -848,7 +849,9 @@ def test_session_config_respects_audio_block_and_output_modalities(self, model):
848849
)
849850
assert turn_detection_mapping["create_response"] is True
850851
assert turn_detection_mapping["silence_duration_ms"] == 450
852+
assert turn_detection_mapping["model_version"] == "default"
851853
assert "silenceDurationMs" not in turn_detection_mapping
854+
assert "modelVersion" not in turn_detection_mapping
852855

853856
@pytest.mark.asyncio
854857
async def test_handle_error_event_success(self, model):

0 commit comments

Comments
 (0)