From 1cd11048deeb313522751c68006437fc078448bc Mon Sep 17 00:00:00 2001 From: seymourtang Date: Thu, 20 Aug 2026 15:55:28 +0800 Subject: [PATCH] refactor(vendors): update Azure OpenAI Realtime parameters to make turn detection optional - Modified the Azure OpenAI Realtime vendor documentation to reflect that `turn_detection` is now optional. - Updated the implementation in the AzureOpenAIRealtimeOptions class to allow omitting `turn_detection`. - Adjusted tests to validate the new behavior of allowing the omission of `turn_detection`. --- docs/concepts/vendors.md | 2 +- docs/reference/vendors.md | 2 +- src/agora_agent/agentkit/vendors/mllm.py | 7 +++++-- tests/custom/test_request_body.py | 7 ++++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/concepts/vendors.md b/docs/concepts/vendors.md index 34e2970..eb10c83 100644 --- a/docs/concepts/vendors.md +++ b/docs/concepts/vendors.md @@ -152,7 +152,7 @@ Used with `agent.with_mllm()` for the [MLLM flow](../guides/mllm-flow.md). These | Class | Provider | Area | Required Parameters | |---|---|---|---| | `OpenAIRealtime` | OpenAI Realtime | Global | `api_key`; optional `turn_detection` | -| `AzureOpenAIRealtime` | Azure OpenAI Realtime | Global | `api_key`, `url`, `turn_detection`; optional `max_history` | +| `AzureOpenAIRealtime` | Azure OpenAI Realtime | Global | `api_key`, `url`; optional `turn_detection`, `max_history` | | `GeminiLive` | Google Gemini Live API | Global | `api_key`, `model`; optional `turn_detection` | | `VertexAI` | Vertex AI (Gemini Live) | Global | `model`, `project_id`, `location`, `adc_credentials_string`; optional `turn_detection` | | `XaiGrok` | xAI Grok (`mllm.vendor`: `xai`) | Global | `api_key`; optional `voice`, `language`, `sample_rate`, `turn_detection` | diff --git a/docs/reference/vendors.md b/docs/reference/vendors.md index 073c0b6..fb54cba 100644 --- a/docs/reference/vendors.md +++ b/docs/reference/vendors.md @@ -821,7 +821,7 @@ Global Azure OpenAI Realtime vendor (`mllm.vendor`: `"azure"`). | `output_modalities` | `List[str]` | No | `None` | Output modalities | | `messages` | `List[Dict]` | No | `None` | Conversation messages | | `params` | `Dict[str, Any]` | No | `None` | Additional Azure OpenAI parameters | -| `turn_detection` | `MllmTurnDetectionConfig` | Yes | — | Required MLLM turn detection configuration; overrides top-level `turn_detection` | +| `turn_detection` | `MllmTurnDetectionConfig` | No | `None` | Optional MLLM turn detection configuration; overrides top-level `turn_detection` when provided | ### `QwenOmni` diff --git a/src/agora_agent/agentkit/vendors/mllm.py b/src/agora_agent/agentkit/vendors/mllm.py index bb207b7..e90fe4d 100644 --- a/src/agora_agent/agentkit/vendors/mllm.py +++ b/src/agora_agent/agentkit/vendors/mllm.py @@ -91,7 +91,9 @@ class AzureOpenAIRealtimeOptions(BaseModel): output_modalities: Optional[List[str]] = Field(default=None, description="Output modalities") messages: Optional[List[Dict[str, Any]]] = Field(default=None, description="Conversation messages") params: Optional[Dict[str, Any]] = Field(default=None, description="Additional Azure OpenAI parameters") - turn_detection: MllmTurnDetectionConfig = Field(..., description="MLLM turn detection configuration") + turn_detection: Optional[MllmTurnDetectionConfig] = Field( + default=None, description="MLLM turn detection configuration" + ) failure_message: Optional[str] = Field(default=None, description="Message played on failure") @@ -126,7 +128,8 @@ def to_config(self) -> Dict[str, Any]: config["messages"] = self.messages if self.failure_message is not None: config["failure_message"] = self.failure_message - config["turn_detection"] = self.turn_detection + if self.turn_detection is not None: + config["turn_detection"] = self.turn_detection return config diff --git a/tests/custom/test_request_body.py b/tests/custom/test_request_body.py index f71fd5d..852714b 100644 --- a/tests/custom/test_request_body.py +++ b/tests/custom/test_request_body.py @@ -1326,9 +1326,10 @@ def test_azure_openai_realtime_rejects_input_modalities() -> None: ) -def test_azure_mllm_requires_turn_detection_and_qwen_mllm_requires_url() -> None: - with pytest.raises(ValidationError): - AzureOpenAIRealtime(url="AZURE_URL", api_key="APIKEY") # type: ignore[call-arg] +def test_azure_mllm_allows_omitting_turn_detection_and_qwen_mllm_requires_url() -> None: + agent = Agent(test_client()).with_mllm(AzureOpenAIRealtime(url="AZURE_URL", api_key="APIKEY")) + props = build_properties(agent) + assert "turn_detection" not in props["mllm"] with pytest.raises(ValidationError): QwenOmni( # type: ignore[call-arg]