Skip to content

fix(openai): prevent early channel close causing lost transcripts#1176

Draft
TanmayChaurasia24 wants to merge 2 commits intolivekit:mainfrom
TanmayChaurasia24:fix-openai-transcript-clipping
Draft

fix(openai): prevent early channel close causing lost transcripts#1176
TanmayChaurasia24 wants to merge 2 commits intolivekit:mainfrom
TanmayChaurasia24:fix-openai-transcript-clipping

Conversation

@TanmayChaurasia24
Copy link
Copy Markdown

@TanmayChaurasia24 TanmayChaurasia24 commented Mar 25, 2026

Summary

This PR fixes a critical bug where gpt-realtime-1.5 mostly loses transcript events and stops speaking prematurely instead of continuing autonomously.

Why this happens

In the new gpt-realtime-1.5 model, OpenAI changed the event streaming lifecycle. The model now often fires the response.output_item.done event before it finishes asynchronously sending all response.output_audio_transcript.delta chunks.

Because handleResponseOutputItemDone was aggressively closing itemGeneration.textChannel and audioChannel, any transcript chunks that arrived even a millisecond later were bouncing off a closed channel and getting completely lost.

Changes

  • Removed textChannel.close() and audioChannel.close() from handleResponseOutputItemDone.
  • The channels will now stay open until the final sweep correctly runs in handleResponseDone(), guaranteeing no trailing transcript strings are lost.

Note: As this is my first contribution, I don't currently have an active OpenAI API key to run a live connection test to gpt-realtime-1.5 locally. However, this perfectly mirrors the reported issue logic. Could a maintainer run a quick live agent test to verify?

Fixes #1133

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 25, 2026

⚠️ No Changeset found

Latest commit: e707950

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 25, 2026

CLA assistant check
All committers have signed the CLA.

devin-ai-integration[bot]

This comment was marked as resolved.

@toubatbrian
Copy link
Copy Markdown
Contributor

@TanmayChaurasia24 I tried on my end but couldn't reproduce the scenario you mentioned. Could you make a short demo on that? Or if there's any logs that would be super helpful!

@TanmayChaurasia24
Copy link
Copy Markdown
Author

@toubatbrian, thanks for taking a look!

As I mentioned in the PR description, I don't currently have an active OpenAI API key to record a live demo of the gpt-realtime-1.5 model.

Specifically, response.output_item.done is firing before the final response.output_audio_transcript.delta chunks are emitted. In the current code, handleResponseOutputItemDone closes the channels immediately, causing those trailing chunks to be dropped.

If you have a test environment, you can verify this by logging the arrival order of those two events. My fix ensures the channels stay open until the final handleResponseDone sweep.

@TanmayChaurasia24 TanmayChaurasia24 marked this pull request as draft April 4, 2026 20:47
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.

RealtimeModel (GA) with gpt-realtime-1.5: incomplete transcripts and turn detection issues

3 participants