Skip to content

fix(openai): forward session.update on RealtimeModel.update_options#5531

Merged
longcw merged 2 commits intomainfrom
longc/fix-realtime-update-options-race
Apr 23, 2026
Merged

fix(openai): forward session.update on RealtimeModel.update_options#5531
longcw merged 2 commits intomainfrom
longc/fix-realtime-update-options-race

Conversation

@longcw
Copy link
Copy Markdown
Contributor

@longcw longcw commented Apr 23, 2026

Summary

RealtimeSession.update_options() compared against the shared RealtimeModel._opts, but RealtimeModel.update_options() mutated that same dict before forwarding to sessions. The diff always saw "no change" and no session.update was sent to OpenAI.

Give each RealtimeSession its own _opts copy so the per-session diff is independent of the model-level state and of any other sessions sharing the same model.

Fixes #5530

RealtimeSession.update_options() compared against the shared
RealtimeModel._opts, but RealtimeModel.update_options() mutated that
same dict before forwarding to sessions. The diff always saw "no
change" and no session.update was sent.

Give each RealtimeSession its own _opts copy so the per-session diff is
independent of the model-level state and of any other sessions sharing
the same model.

Fixes #5530
@chenghao-mou chenghao-mou requested a review from a team April 23, 2026 02:06
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Copy link
Copy Markdown
Member

@chenghao-mou chenghao-mou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Two nits.

Address review feedback:
- Use dataclasses.replace() for the per-session opts copy
- Standardize all self._realtime_model._opts reads in RealtimeSession to
  use the per-session self._opts for consistency
@longcw longcw merged commit 2723fc9 into main Apr 23, 2026
24 checks passed
@longcw longcw deleted the longc/fix-realtime-update-options-race branch April 23, 2026 03:02
Copy link
Copy Markdown
Contributor

This is an automated Claude Code Routine created by @toubatbrian. Right now it is in experimentation stage. The automation will start porting this PR into agents-js automatically.

Detected classification: plugin fix (OpenAI Realtime). This PR fixes a per-session state diff bug in RealtimeSession.update_options(), which is plugin-level behavior that also applies to the JS port. Initiating a port to livekit/agents-js now.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RealtimeModel.update_options() does not send session.update to OpenAI (race condition with _opts mutation)

3 participants