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:
from 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
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 callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /agents, current file: none) bash-$
- Assistant
I’ll first locate the Python OpenAI realtime implementation and its tests/types, then trace how constructor options become session update payloads so the change follows existing conventions.
- Assistant
rgis unavailable, so I’ll usegrep/findto identify the implementation and relevant test coverage. - Assistant
I found a single realtime model module. I’ll inspect its option types, constructor, option-copy/update paths, and session payload construction before editing, because a new field often must be propagated through several immutable option objects.
- Assistant
The field must be represented in
_RealtimeOptions, accepted byRealtimeModel, included in the GA session request, and likely supported by both model-level and live sessionupdate_options. I’ll inspect those exact sections plus the installed OpenAI SDK’s generated reasoning type to avoid inventing an incompatible annotation. - Assistant
The base interpreter lacks project dependencies. I’ll inspect the pinned OpenAI version and generated types in the lock/cache via the repository’s
uvenvironment, and locate plugin-specific tests (which may live outside the package directory). - Assistant
The installed SDK already exposes
RealtimeReasoning, so the clean public API can accept that SDK type while also naturally accepting the requested dictionary at runtime through Pydantic. I’ll print its schema and inspect existing tests’ mocking/assertion style before implementing. - Assistant
Because the requested example specifically passes a plain dict, I’ll check whether the SDK provides a parameter
TypedDictin addition to the response model. Using a parameter type would preserve static type-checking for exactly that syntax. - Assistant
I’ll implement a small normalizer so both SDK models and typed dictionaries are accepted and invalid effort values fail early. The option will be included in initial session creation and in model/session updates; legacy Azure conversion will continue dropping it because that API does not support the field.
- Assistant
The implementation is in place. I’ll now format and type-check it, then run a focused reproduction that instantiates exactly the requested dictionary API and inspects both initial and incremental serialized payloads. This will also reveal whether Pydantic omits
Nonecorrectly and whether dynamic clearing is represented. - Assistant
Formatting, linting, and strict file-level type checking pass. I’ll run the focused async reproduction now, capturing
send_eventfor updates and asserting all documented effort values are accepted while an invalid value is rejected. - Assistant
The assertions pass, but the temporary reproduction exposed an unclosed session created by
RealtimeSession; I’ll inspect its lifecycle and rerun with proper cleanup so verification itself is clean. I’ll also inspect repository test configuration to choose the smallest relevant existing suite. - Assistant
RealtimeSession.aclose()owns the active connection task, so I’ll rerun with both session and model closed. Then I’ll run the existing realtime unit tests; although they test the framework rather than this plugin directly, they are the nearest affected suite available. - Assistant
The focused reproduction is clean and passes. The existing realtime suite cannot start because it is an external-provider integration suite and
OPENAI_API_KEYis absent; this is environmental, before any session behavior is exercised.One compatibility concern remains: the plugin currently declares
openai>=2, whileRealtimeReasoningmay have been introduced in a later 2.x release. I’ll identify the locked SDK version and inspect dependency conventions so the package cannot install against a version lacking the imported type. - Assistant
The lock uses OpenAI 2.40.0 and no dependency file change is needed for the current workspace. I’ll do a final edge-case check for clearing reasoning with
None, confirmgpt-realtime-2is represented in the model literal (adding it if appropriate), and review the complete diff/status before submission. - Assistant
One subtle payload issue is worth checking before finalizing: because the initial request constructor receives
reasoning=Noneexplicitly, an unspecified option might serialize as"reasoning": null. Existing serialization may excludeNone, but if not, this would alter all realtime sessions. I’ll inspect serialization and verify the default payload does not gain an unwanted field; if it does, I’ll conditionally assign reasoning only when configured. - Assistant
The default request does mark reasoning as set. I’ll inspect the actual websocket dump flags; unless they exclude
None, I’ll adjust initial construction to assign the field only when configured, matching how optional truncation is already handled. - Assistant
Actual websocket serialization does not exclude
None, so I’ll prevent a regression by following the existing truncation pattern: only set reasoning on initial payloads when configured. Explicit dynamicreasoning=Nonewill still sendnullto clear a prior setting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →