fix: migrate OpenAI realtime websocket to GA#1005
Conversation
- OpenAI rejected Realtime websocket connections that still sent the beta negotiation header, and the old flat session/event shape could fail after the connection moved to the GA interface. - Remove the beta header, send the session audio config in the GA shape, and keep legacy event names alongside GA names so existing streaming and Twilio paths continue to work. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@codex review |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthroughThis PR updates the OpenAI realtime integration to conform to a newer API schema. Audio format initialization switches from Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
LGTM — the beta→GA migration matches OpenAI's official migration guide (beta header removed, session.type: "realtime", nested audio.input/audio.output, audio/pcmu format objects, and the response.output_* event renames). Verified the migration is complete across the codebase (no lingering old event names or beta header), and CI is green.
One follow-up (non-blocking): we should stop accepting temperature in run_openai_audio. GA removed temperature as a model parameter, so it's correctly gone from the session payload — but run_openai_audio still clamps it to the old beta range (0.6, 1.2) and threads it into init_ws_session, which no longer uses it. It's now dead plumbing. Recommend dropping the clamp and the temperature param from init_ws_session (and the temperature= kwarg at the call site in language_model.py) so it's clear the value is intentionally not sent.
Realtime GA session setup does not use chat temperature; drop the unused param and clamp logic from the audio websocket flow. Co-authored-by: Cursor <cursoragent@cursor.com>
OpenAI rejected Realtime websocket connections that still sent the beta negotiation header, and the old flat session/event shape could fail after the connection moved to the GA interface.
Remove the beta header, send the session audio config in the GA shape, and keep legacy event names alongside GA names so existing streaming and Twilio paths continue to work.
https://developers.openai.com/api/docs/guides/realtime#beta-to-ga-migration
Q/A checklist
How to check import time?
You can visualize this using tuna:
To measure import time for a specific library:
To reduce import times, import libraries that take a long time inside the functions that use them instead of at the top of the file:
Legal Boilerplate
Look, I get it. The entity doing business as “Gooey.AI” and/or “Dara.network” was incorporated in the State of Delaware in 2020 as Dara Network Inc. and is gonna need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Dara Network Inc can use, modify, copy, and redistribute my contributions, under its choice of terms.