ITADN

AttributeError: 'str' object has no attribute 'type' in _handle_response_done_but_not_complete when using xAI-compatible Realtime API

#5993Closedareebkhan-tech 创建于 2026-06-07
bug
A
areebkhan-techcommented
### Bug Description When using an OpenAI-compatible Realtime API (e.g. xAI), the `response.done` event sometimes returns `status_details` as a plain string (e.g. `"incomplete"`) instead of a structured object `{"type": "incomplete", ...}`. In `realtime_model.py`, the event is constructed via `ResponseDoneEvent.construct(**event)` (line 1117), which bypasses Pydantic validation and leaves `status_details` as a raw string. Later, `_handle_response_done_but_not_complete` (line 2057) accesses `status_details.type`, crashing with: AttributeError: 'str' object has no attribute 'type' Full traceback: File "realtime_model.py", line 1117, in _recv_task self._handle_response_done(ResponseDoneEvent.construct(**event)) File "realtime_model.py", line 2023, in _handle_response_done self._handle_response_done_but_not_complete(event) File "realtime_model.py", line 2057, in _handle_response_done_but_not_complete status_type = status_details.type if status_details else None AttributeError: 'str' object has no attribute 'type' ### Expected Behavior Either: 1. `ResponseDoneEvent.construct()` should be replaced with proper Pydantic parsing (e.g. `ResponseDoneEvent.model_validate()`) so `status_details` is always coerced into a `RealtimeResponseStatus` object, OR 2. Lines 2057-2058 should guard against a plain string: status_type = status_details.type if hasattr(status_details, "type") else status_details status_reason = status_details.reason if hasattr(status_details, "reason") else None ### Reproduction Steps ```bash When using an OpenAI-compatible Realtime API (e.g. xAI), the `response.done` event sometimes returns `status_details` as a plain string (e.g. `"incomplete"`) instead of a structured object `{"type": "incomplete", ...}`. ``` ### Operating System macOS ### Models Used _No response_ ### Package Versions ```bash livekit ==1.1.8 livekit[agnet]==1.5.17 ``` ### Session/Room/Call IDs _No response_ ### Proposed Solution ```python ``` ### Additional Context _No response_ ### Screenshots and Recordings _No response_
关闭于 2026-06-08 0 条评论