Skip to content

feat(openai): add realtime reasoning option#1699

Closed
rosetta-livekit-bot[bot] wants to merge 2 commits into
mainfrom
neck-confound-routes
Closed

feat(openai): add realtime reasoning option#1699
rosetta-livekit-bot[bot] wants to merge 2 commits into
mainfrom
neck-confound-routes

Conversation

@rosetta-livekit-bot
Copy link
Copy Markdown
Contributor

@rosetta-livekit-bot rosetta-livekit-bot Bot commented Jun 2, 2026

available for gpt-realtime-2

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 2, 2026

🦋 Changeset detected

Latest commit: cad5ba1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 34 packages
Name Type
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-xai Patch
@livekit/agents Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugins-test Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review

Comment on lines +809 to +814
const currentReasoning = this._options.reasoning ?? null;
const nextReasoning = reasoning ?? null;
if (currentReasoning !== nextReasoning) {
options.reasoning = reasoning;
hasChanges = true;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Object reference equality comparison for reasoning always detects change for non-null objects

In updateOptions, the reasoning change detection at line 811 uses !== (reference equality) to compare the current and next reasoning objects. Since each call typically provides a new object literal (e.g., { effort: 'medium' }), the comparison will always evaluate to true for non-null values, even when the content is identical. This defeats the no-op optimization that the hasChanges flag is designed to provide (contrast with toolChoice, where toOaiToolChoice() normalizes to a string for proper value comparison). Every repeated updateOptions({ reasoning: { effort: 'medium' } }) call sends a redundant session.update event to the server.

Prompt for agents
In updateOptions() in plugins/openai/src/realtime/realtime_model.ts, the reasoning change detection at lines 809-814 uses reference equality (currentReasoning !== nextReasoning) for object comparison. Since RealtimeReasoning is an object type (with an effort field), two objects with identical content but different references will always appear different. This means calling updateOptions({ reasoning: { effort: 'medium' } }) twice will always send a redundant session.update event.

To fix this, implement a value-based comparison, for example by comparing the serialized effort field:
  const currentEffort = (this._options.reasoning ?? null)?.effort ?? null;
  const nextEffort = (reasoning ?? null)?.effort ?? null;
  if (currentEffort !== nextEffort) { ... }

Alternatively, use JSON.stringify for a deep comparison, though this is more fragile if new fields are added to RealtimeReasoning.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant