Skip to content

fix(openai): restore realtime context across task transitions - #2180

Open
toubatbrian wants to merge 2 commits into
mainfrom
fix/openai-realtime-config-history
Open

fix(openai): restore realtime context across task transitions#2180
toubatbrian wants to merge 2 commits into
mainfrom
fix/openai-realtime-config-history

Conversation

@toubatbrian

@toubatbrian toubatbrian commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Problem

Exiting an AgentTask can reuse an OpenAI realtime session with framework-only metadata in the merged chat context. Serialization then fails, leaving provider history stale; restored items were also appended instead of inserted before the task history.

Fix

Filter agent handoff and configuration records before computing provider updates, and use OpenAI's root anchor when prepending restored history.

Testing

OpenAI realtime suite: 45 tests passed. Full build and formatting checks pass.

Python parity

Matches all three metadata-filtering paths in Python OpenAI realtime—chat updates, reconnect, and transcript synchronization—through their shared JS event builder. Root insertion also matches Python's previous_item_id="root" behavior.

Filter session-only history records before computing OpenAI realtime context updates so task transitions can restore provider-visible conversation history.

Co-authored-by: Cursor <cursoragent@cursor.com>
@toubatbrian
toubatbrian requested a review from a team as a code owner July 30, 2026 21:40
@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3283fce

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

This PR includes changesets to release 39 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-krisp 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-anthropic Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-azure Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did 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-protoface 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

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

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.

✅ Devin Review: No Issues Found

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

View in Devin Review to see 1 additional finding.

Open in Devin Review

Use OpenAI's root anchor for prepended context items so task exits restore parent history in the same order as Python.

Co-authored-by: Cursor <cursoragent@cursor.com>
@toubatbrian toubatbrian changed the title fix(openai): ignore metadata in realtime chat updates fix(openai): restore realtime context across task transitions Jul 30, 2026
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.

2 participants