From 902f53cc1321f6f09eb7f594ee1a2bfa5ed9d356 Mon Sep 17 00:00:00 2001 From: Lucas Wang Date: Tue, 21 Oct 2025 12:45:27 +0800 Subject: [PATCH] fix: Remove trailing commas causing tuple assignment in response cancellation The trailing commas on lines 434 and 619 were creating tuples instead of booleans for automatic_response_cancellation_enabled. This caused the condition 'if not automatic_response_cancellation_enabled' to always evaluate to False, preventing _cancel_response() from being called. Impact: Response cancellation was completely broken when interrupt_response=False Fix: Remove trailing commas to return bool instead of tuple Verification: - Before fix: type=tuple, not (False,) = False -> _cancel_response() NOT called - After fix: type=bool, not False = True -> _cancel_response() IS called - All 23 tests pass --- src/agents/realtime/openai_realtime.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/agents/realtime/openai_realtime.py b/src/agents/realtime/openai_realtime.py index 50aaf3c4b..ce28114c9 100644 --- a/src/agents/realtime/openai_realtime.py +++ b/src/agents/realtime/openai_realtime.py @@ -431,7 +431,7 @@ async def _send_interrupt(self, event: RealtimeModelSendInterrupt) -> None: and session.audio is not None and session.audio.input is not None and session.audio.input.turn_detection is not None - and session.audio.input.turn_detection.interrupt_response is True, + and session.audio.input.turn_detection.interrupt_response is True ) if not automatic_response_cancellation_enabled: await self._cancel_response() @@ -616,7 +616,7 @@ async def _handle_ws_event(self, event: dict[str, Any]): and session.audio is not None and session.audio.input is not None and session.audio.input.turn_detection is not None - and session.audio.input.turn_detection.interrupt_response is True, + and session.audio.input.turn_detection.interrupt_response is True ) if not automatic_response_cancellation_enabled: await self._cancel_response()