ISSUE DESCRIPTION Add reasoning.effort support for OpenAI gpt-realtime-2 Feature Type…
- User
ISSUE DESCRIPTION
Add reasoning.effort support for OpenAI gpt-realtime-2
Feature Type
Would make my life easier
Feature Description
OpenAI
gpt-realtime-2supports configurable reasoning viareasoning.effort, but the Python OpenAI Realtime plugin does not seem to expose this option onopenai.realtime.RealtimeModel.It would be useful to support something like:
pythonfrom livekit.plugins import openai llm = openai.realtime.RealtimeModel( model="gpt-realtime-2", reasoning={"effort": "low"}, )Workarounds / Alternatives
I don't think there is a clean workaround through the current Python
RealtimeModelAPI.The only workaround I can see is patching the plugin locally to add
reasoningto the session update payload.Additional Context
OpenAI docs list these effort values:
minimal,low,medium,high,xhigh.References:
- https://developers.openai.com/api/docs/models/gpt-realtime-2
- https://developers.openai.com/api/docs/guides/realtime-models-prompting#set-reasoning-effort
- Related JS issue: https://github.com/livekit/agents-js/issues/1433
- Related JS PR: https://github.com/livekit/agents-js/pull/1575
Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. - Assistant
I'll explore the repository to find the OpenAI Realtime plugin and how session options are passed, then add
reasoning.effortsupport. - Assistant
Let me look at the OpenAI realtime plugin in livekit-plugins.
- Assistant
I'll inspect the OpenAI RealtimeModel and related types, and check how the JS PR handled reasoning.
- Assistant
Let me search with grep instead of rg.
- Assistant
I'll open the RealtimeModel constructor and how session update events are built.
- Assistant
Let me continue reading the RealtimeModel init and session creation methods.
- Assistant
Next I'll inspect session update construction and related models, and check the JS PR for the intended shape.
- Assistant
I'll check the JS implementation and how other plugins expose similar options.
- Assistant
I'll review how similar options like truncation were wired through, and inspect the responses LLM reasoning pattern.
- Assistant
I have enough context to wire
reasoningthrough options and session updates the same way astruncation. Reading the remaining constructor section next. - Assistant
I'll check what's exported from the OpenAI realtime types package.
- Assistant
I'll use the venv Python to verify the imports.
- Assistant
Implementing the
reasoningparameter across options, constructors, and session updates. - Assistant
I'll open the imports section and apply the edit there.
- Assistant
Good, now I can use replace.
- Assistant
Next I'll add reasoning to
_RealtimeOptionsand a small normalizer helper. - Assistant
I'll add a
_to_reasoninghelper and the field. Looking at utils for pattern of conversion functions. - Assistant
I'll put a small converter in utils for consistency with the other helpers.
- Assistant
I'll add to_reasoning and update imports.
- Assistant
Now add to_reasoning after to_noise_reduction.
- Assistant
Updating
realtime_model.pyto support the reasoning option end-to-end. - Assistant
Continue with multiple replacements.
- Assistant
Now add field to _RealtimeOptions
- Assistant
I'll add reasoning field after truncation in _RealtimeOptions and in all overloads.
- Assistant
Updating all three
__init__signatures next. - Assistant
Update azure overload and actual init
- Assistant
Updating the docstring and
_optsconstruction next. - Assistant
Now update _opts construction.
- Assistant
I need to jump to line 480 first.
- Assistant
Continue with replace
- Assistant
Updating
update_optionson the model and session, plus session update creation. - Assistant
Update the update_options method
- Assistant
Fixing reasoning forwarding so we only send it to the session when it was actually provided.
- Assistant
Next I'll update
_create_session_update_eventand the session'supdate_options. - Assistant
I'll update create session and session update_options
- Assistant
Update session.update_options signature and body for reasoning.
- Assistant
I'll verify how session update events are serialized when optional fields are None.
- Assistant
Checking whether xAI realtime subclasses this and needs updates.
- Assistant
I'll run a quick script to verify the feature works end-to-end.
- Assistant
I'll rerun the check under asyncio.
- Assistant
Confirming the plugin's openai dependency includes RealtimeReasoning.
- Assistant
I'll review the full diff to confirm everything landed correctly.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.