fix(openai realtime): keep derived capabilities in sync with update_options - #6943
Merged
Merged
Conversation
…ptions `capabilities.turn_detection` and `capabilities.user_transcription` are derived from constructor options, but `update_options` changed those options without recomputing them. A model switched to `create_response=False` is doing client-side turn taking (#6642), yet the stale capability still reported the server owning the turn: `AgentActivity` then refuses `allow_interruptions=False`, and `_resolve_rt_turn_detection_enabled` picks the wrong mode for endpointing and for realtime-session reuse across a handoff. The turn-taking derivation now lives in one function used by both the constructor and `update_options`, so the two cannot drift apart again. It also carries the `interrupt_response` warning, which `update_options` never emitted. Turn detection is per session as well, since `session(turn_detection_disabled=True)` switches it off for one session while the model keeps it. `RealtimeSession` now holds its own capabilities copy and updates it from its own `update_options`, so a session can hand turn taking to the client without changing what the model or its other sessions report.
The interrupt_response warning was a side effect of deriving the capability, and update_options re-runs that derivation on every session the model owns, so one call logged the warning 1 + N times. The derivation is pure now and only the model warns.
davidzhao
approved these changes
Aug 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
capabilities.turn_detectionandcapabilities.user_transcriptioncome from constructor options, butupdate_optionschanged those options and left the capabilities alone.A model switched to
create_response=Falsedoes client-side turn taking (#6642), and the stale capability still reports that the server owns the turn.AgentActivitythen refusesallow_interruptions=False, and_resolve_rt_turn_detection_enabledselects the wrong mode for endpointing and for realtime-session reuse across a handoff.Turn detection is also per session, because
session(turn_detection_disabled=True)switches it off for one session, but the only capabilities object was on the model.Fix
One function now derives server-side turn taking, and both the constructor and
update_optionscall it, so the two cannot drift apart again.RealtimeSessionkeeps its own capabilities copy and updates it from its ownupdate_options.One session can now hand turn taking to the client while the model and its other sessions stay unchanged.
The function also carries the
interrupt_responsewarning, whichupdate_optionsdid not give before.The
turn_detection_disabledbranch in the session constructor has no unit test, because a real session opens a websocket in__init__.