Skip to content

fix(xai): emit interim realtime transcripts#1912

Open
rosetta-livekit-bot[bot] wants to merge 1 commit into
mainfrom
nonesuch-bowman-befogged
Open

fix(xai): emit interim realtime transcripts#1912
rosetta-livekit-bot[bot] wants to merge 1 commit into
mainfrom
nonesuch-bowman-befogged

Conversation

@rosetta-livekit-bot

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

Copy link
Copy Markdown
Contributor

Summary

  • emit xAI realtime status: "in_progress" transcription events as interim transcripts
  • avoid mutating chat context until the final completed transcript arrives
  • add a changeset for the xAI plugin patch release

Testing

  • pnpm build:plugins
  • pnpm test -- plugins/openai/src/realtime/realtime_model.test.ts
  • pnpm prettier --check plugins/openai/src/realtime/api_proto.ts plugins/openai/src/realtime/realtime_model.ts plugins/openai/src/realtime/realtime_model.test.ts

Port of livekit/agents#6272.


Ported from livekit/agents#6272

Original PR description

Fixes #6271

xAI streams partial transcripts through the same conversation.item.input_audio_transcription.completed event as the final one, distinguishing them with a status field ("in_progress" vs "completed"). The handler delegated to the OpenAI base handler, which ignores status and always emits is_final=True, so every partial was surfaced as a final transcription and produced a duplicate conversation item for a single utterance.

Emit InputTranscriptionCompleted(is_final=False) for in-progress transcripts and only delegate to the base handler (is_final=True) for the final one. A missing status defaults to final.

@changeset-bot

changeset-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 59d9e12

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

This PR includes changesets to release 35 packages
Name Type
@livekit/agents-plugin-xai Patch
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld 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-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam 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

@rosetta-livekit-bot rosetta-livekit-bot Bot requested a review from longcw June 30, 2026 03:21

@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 found 1 potential issue.

Open in Devin Review

Comment on lines +1577 to +1583
if (event.status === 'in_progress') {
this.emit('input_audio_transcription_completed', {
itemId: event.item_id,
transcript: event.transcript,
isFinal: false,
});
return;

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.

🚩 Failure path produces no final event when only in_progress completed events were received

If xAI sends only completed(in_progress) events (no deltas) and then a transcription.failed event, finalizePartialOnTranscriptionFailure at plugins/openai/src/realtime/realtime_model.ts:1616 will find no accumulator entry (since in_progress doesn't populate it) and return without emitting an isFinal: true event. Consumers waiting for a final transcript would never receive one. In the normal OpenAI flow this doesn't happen because deltas populate the accumulator. This is a narrow edge case (failure after in-progress events from xAI) and may not be worth handling, but reviewers should be aware.

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.

0 participants