-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
Description
Summary
Response cancellation is completely broken in the Realtime API due to trailing commas creating tuples instead of booleans.
Bug Location
src/agents/realtime/openai_realtime.py lines 434 and 619
Description
The trailing commas in the automatic_response_cancellation_enabled assignment create single-element tuples instead of booleans:
# Current (buggy) code:
automatic_response_cancellation_enabled = (
session
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, # ← Trailing comma
)Impact
The condition if not automatic_response_cancellation_enabled: always evaluates to False because:
- With trailing comma:
type = tuple, value =(False,),not (False,) = False - Non-empty tuples are always truthy in Python
Result: _cancel_response() is never called, breaking response cancellation when interrupt_response=False.
Reproduction
# Demonstrates the bug:
enabled = (False,) # tuple
print(not enabled) # False - _cancel_response() NOT called!
# Expected behavior:
enabled = False # bool
print(not enabled) # True - _cancel_response() IS calledEnvironment
- Introduced in: PR feat: #1614 gpt-realtime migration (Realtime API GA) #1646 (commit 9168348, 2025-09-12)
- Affects: All Realtime API users with
interrupt_response=False
Fix
Remove the trailing commas on lines 434 and 619.
I'll submit a PR with the fix.