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 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 first locate the Python OpenAI realtime implementation, its option types, payload construction, and relevant tests. Then I’ll reproduce the missing constructor option, implement the feature consistently with existing conventions, and run focused tests plus broader checks as practical.
- Assistant
The repository is a monorepo and the initial class search did not return results, so I’ll inspect the OpenAI plugin tree and search more generally for realtime modules and session update serialization.
- Assistant
ripgrepis unavailable in this environment, so I’ll usegrepand open the implementation in sections, including constructor option definitions and session update generation. - Assistant
I found
_RealtimeOptionsand the OpenAI/Azure conversion boundary. I’ll read the complete constructor overloads, copy/update behavior, and_update_sessionmethod to determine wherereasoningmust persist and how the SDK model is serialized. - Assistant
The prior output was truncated around forwarding logic and the session model fields. I’ll inspect narrower ranges and query the installed OpenAI SDK to see whether its
RealtimeSessionCreateRequestalready typesreasoning, including the exact generated type and accepted effort literals. This affects whether to use SDK types or a local compatibility type. - Assistant
The pinned SDK already supports
RealtimeSessionCreateRequest.reasoningasRealtimeReasoning, which is ideal. The feature should likely be constructor-level and dynamically updateable, matching all other session options. I’ll inspect the public SDK type, session option copy/update path, model list, and project lint/type-test commands before editing. - Assistant
The SDK effort literals exactly match the issue, and
gpt-realtime-2is already in the model literal. I’ll addRealtimeReasoningto imports and options, exposereasoningon the OpenAI constructor (and likely Azure overload for signature consistency), serialize it in session updates, and support runtime updates through model/session forwarding. First I’ll read the remainder of the session update method to preserve its changed-flag behavior. - Assistant
To make the documented dictionary form type-safe rather than merely runtime-compatible, I’ll check whether the SDK provides a
RealtimeReasoningConfig/parameterTypedDict. If so, I’ll use that alongside the Pydantic response model; otherwise I’ll define a small public-compatible typed dict locally. - Assistant
The SDK provides exactly the request-side
RealtimeReasoningParamTypedDict and the model-sideRealtimeReasoning, so no local type is needed. I’ll use the parameter type in public APIs, normalize it toRealtimeReasoninginternally, and include the field in initial and incremental session updates. I’ll also forward it fromwith_azure; legacy Azure serialization will intentionally continue dropping unsupported fields via its explicit converter. - Assistant
A nullable edge case surfaced in review:
reasoning=Noneshould clear/omit reasoning, butmodel_validate(None)would reject it. I’ll add a normalization helper so both dictionaries and explicitNonebehave correctly, then run formatter/linter/type checking. I’ll also use a temporary (uncommitted) script to inspect the exact serialized initial and incremental payloads without opening a network connection. - Assistant
The focused payload reproduction passes for
low,xhigh, deduplicated updates, and clearing withNone; mypy also passes. Ruff only requested alphabetic import ordering, which I’ll auto-fix. Then I’ll inspect the final diff/status, run the plugin’s available pytest scope (if any), and validate all five documented effort values plus invalid-value rejection. - Assistant
The implementation and checks are clean, and the package has no collected tests. One final compatibility review remains: because the dependency is broadly
openai>=2, I’ll verify the lockfile version that introduced these SDK types and ensure accepting both the issue’s dictionary form and the SDK’sRealtimeReasoningobject is reflected in type hints. Then I’ll rerun concise final checks and submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.