fix(openai realtime): keep derived capabilities in sync with updateOptions - #2323
fix(openai realtime): keep derived capabilities in sync with updateOptions#2323rosetta-livekit-bot[bot] wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 932a46e The changes in this PR will be included in the next version bump. This PR includes changesets to release 39 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| session.updateOptions({ | ||
| ...options, | ||
| turnDetection: | ||
| options.turnDetection !== undefined ? this._options.turnDetection : undefined, | ||
| inputAudioTranscription: this._options.inputAudioTranscription, | ||
| }); |
There was a problem hiding this comment.
🟡 Model option updates overwrite per-session transcription config
updateOptions gates turnDetection behind options.turnDetection !== undefined when forwarding to sessions but forwards inputAudioTranscription unconditionally as this._options.inputAudioTranscription. Any model-level update, even one changing only voice, then resets every session's transcription setting and userTranscription capability to the model's value, discarding session-specific customization.
| session.updateOptions({ | |
| ...options, | |
| turnDetection: | |
| options.turnDetection !== undefined ? this._options.turnDetection : undefined, | |
| inputAudioTranscription: this._options.inputAudioTranscription, | |
| }); | |
| session.updateOptions({ | |
| ...options, | |
| turnDetection: | |
| options.turnDetection !== undefined ? this._options.turnDetection : undefined, | |
| inputAudioTranscription: | |
| options.inputAudioTranscription !== undefined | |
| ? this._options.inputAudioTranscription | |
| : undefined, | |
| }); |
Was this helpful? React with 👍 or 👎 to provide feedback.
Ports livekit/agents#6943 to the JS OpenAI Realtime implementation.
Summary
Source diff coverage
Source diff coverage
livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/realtime_model.pyplugins/openai/src/realtime/realtime_model.ts; camelCase and JS OpenAI wire types are used for the shared capability derivation, model/sessionupdateOptions, active-session propagation, warning, and per-session capability copy.agents/src/llm/realtime.tsadds the prerequisite default session capability getter that already exists in Python but was absent in JS.tests/test_realtime/test_openai_realtime_model.pyplugins/openai/src/realtime/realtime_model.test.ts; all three tests added by #6943 are ported to Vitest using the existing task stub instead of PythonSimpleNamespace.No source files were not applicable.
Validation
pnpm test agents: 112 files passed, 1522 tests passed, 5 skippedenv -u OPENAI_API_KEY pnpm test plugins/openai: 5 files passed, 2 skipped; 75 tests passed, 7 skippedpnpm test plugins/openai/src/realtime/realtime_model.test.ts: 50 tests passedpnpm build: 40 workspace tasks passedpnpm --filter @livekit/agents-plugin-openai build: passedcue-cli: live OpenAI Realtime text turn passed afterupdateOptionsdisabled server turn taking; assistant framework event resolved in 812 msPackage-wide lint was run for both touched packages. It remains blocked by existing repository formatting failures (184 findings in
@livekit/agents, 15 in the OpenAI plugin) under the available Node 20/pnpm 9 environment; the repository declares pnpm 11, which requires Node 22 and cannot run here.Ported from livekit/agents#6943
Original PR description
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__.