Skip to content

fix(voice): await initRecording() to prevent OTEL trace loss in short sessions#1300

Merged
toubatbrian merged 2 commits intolivekit:mainfrom
moyounishimself:fix/await-initRecording
Apr 28, 2026
Merged

fix(voice): await initRecording() to prevent OTEL trace loss in short sessions#1300
toubatbrian merged 2 commits intolivekit:mainfrom
moyounishimself:fix/await-initRecording

Conversation

@moyounishimself
Copy link
Copy Markdown
Contributor

Summary

ctx.initRecording() in AgentSession.start() is called without await, creating a race condition where the OTLP exporter may not be connected before session events fire. This causes intermittent "No observability data available" in Agent Insights — particularly for short sessions without tool calls, where the session ends before the cloud tracer finishes initializing.

Sessions with tool calls (which take longer due to API round-trips) give the tracer enough time to connect, masking the issue. The session report uploads successfully in all cases, but OTEL traces carrying transcripts and audio metadata are lost.

Changes

  • Await ctx.initRecording() in AgentSession.start() so the cloud tracer is ready before any events fire

Test plan

  • Deployed with a manual workaround (await ctx.initRecording() before session.start()) on LiveKit Cloud — Agent Insights data now records consistently for short sessions without tool calls
  • Verified no regression for sessions with tool calls

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 23, 2026

🦋 Changeset detected

Latest commit: 81c453a

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

This PR includes changesets to release 26 packages
Name Type
@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-elevenlabs Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai 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-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai 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

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 23, 2026

CLA assistant check
All committers have signed the CLA.

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 1 additional finding.

Open in Devin Review

@moyounishimself moyounishimself force-pushed the fix/await-initRecording branch from c9c214a to 75554a6 Compare April 24, 2026 01:19
@toubatbrian toubatbrian merged commit 9863518 into livekit:main Apr 28, 2026
6 checks passed
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.

3 participants