Skip to content

fix(room_io): respect outputOptions.audioPublishOptions when publishing audio track - #2076

Merged
toubatbrian merged 1 commit into
livekit:mainfrom
adaro:fix/audio-publish-options
Jul 20, 2026
Merged

fix(room_io): respect outputOptions.audioPublishOptions when publishing audio track#2076
toubatbrian merged 1 commit into
livekit:mainfrom
adaro:fix/audio-publish-options

Conversation

@adaro

@adaro adaro commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #1954.

RoomIO accepts outputOptions.audioPublishOptions and threads it into ParticipantAudioOutput as options.trackPublishOptions, but publishTrack() never read it. It always published with a fresh hardcoded new TrackPublishOptions({ source: TrackSource.SOURCE_MICROPHONE }), so the configured option was silently dropped.

Because the proto fields are optional, unset dtx/red fall through to the Rust FFI defaults (dtx: true, red: true), which means agents could not disable Opus DTX or RED on their output track no matter what they passed. With DTX forced on, TTS audio containing silence padding produces audible gate/pop artifacts at sentence boundaries.

Changes Made

  • ParticipantAudioOutput.publishTrack() now publishes with this.options.trackPublishOptions, keeping the previous hardcoded options as a fallback. No behavior change for callers who don't pass audioPublishOptions: DEFAULT_ROOM_OUTPUT_OPTIONS already supplies new TrackPublishOptions({ source: TrackSource.SOURCE_MICROPHONE }).
  • Added a regression test in _output.test.ts asserting publishTrack() uses the configured options (verified it fails against the previous implementation).
  • Added a changeset (@livekit/agents patch).

Pre-Review Checklist

  • Build passes: All builds (lint, typecheck, tests) pass locally
  • AI-generated code reviewed: Removed unnecessary comments and ensured code quality
  • Changes explained: All changes are properly documented and justified above
  • Scope appropriate: All changes relate to the PR title, or explanations provided for why they're included
  • Video demo: N/A (no UI-facing change; see Testing)

Testing

  • Automated tests added/updated (if applicable)
  • All tests pass

pnpm build (tsup + tsc --declaration), eslint, prettier --check, and vitest run src/voice/room_io/_output.test.ts (6/6) all pass locally. The new test fails without the one-line fix and passes with it.

Additional Notes

The issue includes a runtime repro: publishing with dtx: false, red: false via outputOptions.audioPublishOptions and observing the publisher SDP still negotiating usedtx=1. After this change the configured options reach localParticipant.publishTrack() directly.

🤖 Generated with Claude Code

…ng audio track

ParticipantAudioOutput.publishTrack() ignored the configured
trackPublishOptions and always published with a hardcoded
TrackPublishOptions({ source: SOURCE_MICROPHONE }), so options like
dtx: false / red: false passed via outputOptions.audioPublishOptions
were silently dropped and the track always negotiated the FFI defaults
(dtx and red enabled).

Fixes livekit#1954

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@adaro
adaro requested a review from a team as a code owner July 20, 2026 22:14
@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0179006

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

This PR includes changesets to release 37 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam 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-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-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

CLAassistant commented Jul 20, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@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

@toubatbrian
toubatbrian merged commit 5724826 into livekit:main Jul 20, 2026
6 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 21, 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

3 participants