Skip to content

fix: pass queueSizeMs from RoomOutputOptions through to AudioSource#1207

Merged
toubatbrian merged 3 commits intolivekit:mainfrom
cxyangs:fix/pass-queueSizeMs-to-audiosource
Apr 7, 2026
Merged

fix: pass queueSizeMs from RoomOutputOptions through to AudioSource#1207
toubatbrian merged 3 commits intolivekit:mainfrom
cxyangs:fix/pass-queueSizeMs-to-audiosource

Conversation

@cxyangs
Copy link
Copy Markdown
Contributor

@cxyangs cxyangs commented Apr 6, 2026

Summary

  • AudioOutputOptions already declares queueSizeMs?: number, but ParticipantAudioOutput never forwards it to AudioSource, so the parameter is silently ignored.
  • RoomOutputOptions lacks queueSizeMs entirely, making it impossible for callers to configure the audio output buffer size.

Root Cause

When TTS generates audio significantly faster than real-time (2–10× burst), the AudioSource ring buffer (default queueSizeMs = 1000) overflows. The oldest frames — which are the beginning of the agent's speech — are discarded, resulting in audible truncation of roughly 1 second at the start of each reply.

Fix

  1. _output.ts: Forward options.queueSizeMs to the AudioSource constructor (3rd argument).
  2. room_io.ts: Add queueSizeMs?: number to RoomOutputOptions and pass it through when creating ParticipantAudioOutput.

Backward Compatibility

Fully backward compatible. When queueSizeMs is not specified (undefined), AudioSource uses its existing default of 1000ms — behavior is unchanged for existing users.

Test Plan

  • TypeScript compilation passes (tsc --noEmit)
  • Manual test: configure queueSizeMs: 5000 in RoomOutputOptions and verify speech truncation is resolved
  • Verify that omitting queueSizeMs produces the same behavior as before

When TTS generates audio faster than real-time (2-10x burst), the
AudioSource ring buffer overflows and discards the earliest frames,
causing the beginning of agent speech to be truncated.

AudioOutputOptions already declares `queueSizeMs` but ParticipantAudioOutput
never forwards it to the AudioSource constructor. RoomOutputOptions also
lacks the field entirely, making it impossible for callers to configure.

This patch:
- Adds `queueSizeMs?: number` to `RoomOutputOptions`
- Forwards `options.queueSizeMs` to `AudioSource` in `ParticipantAudioOutput`
- Passes `queueSizeMs` through in `RoomIO.start()`
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 6, 2026

🦋 Changeset detected

Latest commit: 4fb416f

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

This PR includes changesets to release 22 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia 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-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-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 6, 2026

CLA assistant check
All committers have signed the CLA.

@toubatbrian
Copy link
Copy Markdown
Contributor

@cxyangs Could you fix the linting error?

- Prettier: format AudioSource constructor call in _output.ts
- ESLint: use type-only import for Throws in proc_pool.test.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cxyangs cxyangs force-pushed the fix/pass-queueSizeMs-to-audiosource branch from 2987856 to 4fb416f Compare April 7, 2026 06:33
@toubatbrian toubatbrian merged commit e399b9b into livekit:main Apr 7, 2026
6 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 7, 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.

3 participants