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
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 first locate the Python OpenAI realtime implementation and its tests/types, then trace how constructor options become session update payloads so the new option is added consistently.
- Assistant
rgis unavailable, so I’ll usegrep/findand inspect the plugin layout plus relevant test files. - Assistant
I found the implementation in one main module. Next I’ll inspect its option dataclasses/type aliases, constructor/update APIs, and session serialization, alongside test conventions in this plugin.
- Assistant
The installed OpenAI SDK models may not yet expose realtime reasoning, so I need to determine whether the payload should use a typed SDK field or an explicitly injected dictionary field. I’ll inspect the remainder of construction/copy logic and all session-update paths before choosing.
- Assistant
The constructor stores every persistent setting in
_RealtimeOptions, then sessions copy those options. I’ll extract the exact session initialization, update-options signature, and serializer. I’ll also introspect the locked SDK version to see its Pydantic schema forRealtimeSessionCreateRequest. - Assistant
The locked SDK already has a
RealtimeReasoningmodel with the required realtime session field, which avoids custom payload patching. I’ll inspect its accepted effort values and project formatting/type-check configuration, then implement support in the model constructor, model-level updates, session-level updates, initial/reconnect payloads, and Azure handling. - Assistant
The SDK validates exactly
minimal,low,medium,high, andxhigh. To support the issue’s literal dictionary example cleanly (including static typing), I’ll define a smallTypedDictinput shape, normalize it once through the SDK model, and store the validatedRealtimeReasoning. Legacy Azure conversion will intentionally omit it because that old session schema does not support the field; modern OpenAI/Azure payloads retain it. - Assistant
I’ll now edit only the plugin source. The normalization helper will ensure invalid effort values fail immediately with the SDK’s standard validation error, while
Noneremains available to clear/reset reasoning throughupdate_options. - Assistant
The full data path is now covered. I’ll format and lint the changed module, then run a focused temporary runtime check that inspects serialized initial and incremental events for all supported effort values, no-op updates, clearing with
None, invalid-value rejection, and legacy Azure omission. No repository test files will be changed. - Assistant
Lint passes; the isolated mypy invocation reports only pre-existing issues caused by skipped imports and existing ignores, with no errors on the new reasoning code. I noticed one backward-compatibility edge case before runtime testing: serializing
reasoning: nullfor every older realtime model could be rejected. I’ll adjust initial payload creation to omit the field unless configured; explicitNoneon an update will still serialize as a reset when replacing a non-Nonevalue. - Assistant
Focused runtime checks pass for the requested public constructor behavior and edge cases. I’ll now review nearby API-export conventions and the final diff, then run the most relevant existing tests that do not require external OpenAI credentials (or report if the realtime suite is integration-only).
- Assistant
The realtime suite is entirely live integration testing (it constructs clients from environment credentials and contacts OpenAI/Azure), so it is not suitable here without secrets. Since the new typed configuration appears in the public constructor signature, I’ll export it from
openai.realtimefor a complete public API, then run static checks and available repository unit tests around URL/session behavior if present. - Assistant
No dedicated offline OpenAI plugin test files exist in the repository; the only relevant suite is the credentialed realtime integration suite. I’ll perform a final public-import smoke test plus model-level propagation test (the remaining path), inspect the complete diff for accidental changes, and then summarize checklist compliance before submission.
- Assistant
The final diff is coherent, but one packaging concern remains: this implementation relies on the SDK’s newly added
RealtimeReasoningtype. I’ll check the locked SDK version and release metadata; if the plugin’s broadopenai>=2lower bound predates that type, I need either a dependency bump or a compatibility implementation so installations at the declared minimum do not break. - Assistant
The lock uses OpenAI 2.40.0 while the declared minimum is 2.0. I’ll quickly probe several SDK releases in temporary isolated directories to identify the first compatible release, avoiding an unnecessary or incorrect lower-bound bump.
- Assistant
The first probe omitted SDK dependencies, so imports failed before reaching the type check. I’ll rerun it using the repository virtual environment’s dependencies while overriding only the OpenAI package.
- Assistant
The type is absent through 2.35 and present by 2.39, so leaving
>=2would break supported environments at import time. I’ll identify the exact first release, then update the plugin dependency bound accordingly (without manually editing the lock unless project convention requires it). - Assistant
Support first appears at least in 2.36.0. I’ll verify there was no compatible 2.35 patch release and then set the minimum to the earliest confirmed version, regenerating the lock so package metadata stays consistent.
- Assistant
A 2.35.1 patch exists, so I’ll inspect it before choosing the bound.
- Assistant
RealtimeReasoningis absent from 2.35.1 and present in 2.36.0, establishing>=2.36.0as the correct compatibility bound. I’ll update project metadata and refresh the lock; the resolved SDK remains 2.40.0. - Assistant
The lock refresh correctly changed only the dependency metadata. I’ll inspect the small project-file diff (including whitespace), rerun the focused payload test against the finalized dependency state, and run packaging/static validation one last time.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.