Skip to content

fix: handle RoomIO microphone track replacement - #2363

Open
rosetta-livekit-bot[bot] wants to merge 1 commit into
mainfrom
reassess-meals-praise
Open

fix: handle RoomIO microphone track replacement#2363
rosetta-livekit-bot[bot] wants to merge 1 commit into
mainfrom
reassess-meals-praise

Conversation

@rosetta-livekit-bot

@rosetta-livekit-bot rosetta-livekit-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • track concrete microphone identity so RoomIO accepts replacement tracks under the same publication
  • handle SDK track-unsubscribe events authoritatively while ignoring stale events
  • add source-derived replacement, cleanup, and frame-processor lifecycle coverage

Ports livekit/agents#6744.

Verification

  • pnpm test agents (138 files, 2,287 passed, 5 skipped)
  • pnpm --filter @livekit/agents build
  • pnpm --filter @livekit/agents typecheck
  • changed-file ESLint and Prettier checks
  • cue-cli voice-mode session: final microphone transcription followed by the expected assistant framework event
  • pnpm --filter @livekit/agents lint was run; it remains blocked by 25 unrelated existing formatting mismatches elsewhere in the package after the repository lock/config mismatch required a non-frozen dependency install. The changed files pass ESLint and the project formatter.
Source diff coverage
  • Adapted: livekit-agents/livekit/agents/voice/room_io/_input.py -> agents/src/voice/room_io/_input.ts. Ported concrete track identity, authoritative TrackUnsubscribed handling, stale/duplicate event guards, close-state protection, listener cleanup, and replacement stream cleanup. The target uses MultiInputStream cancellation/removal instead of Python asyncio forwarding tasks.
  • Adapted: tests/test_room_io.py -> agents/src/voice/room_io/_input.test.ts. Ported applicable listener cleanup, same-publication replacement, duplicate subscribe, stale unsubscribe, active unsubscribe, superseded-stream cleanup, detached forwarding, and owned frame-processor lifecycle coverage.
  • Not applicable within the adapted test file: the three Python pre-connect-buffer tests because agents-js has no pre-connect audio handler or publication audio-feature path. The Python-only selector processor case also has no target selector API; direct owned processor replacement lifecycle is covered. Python silence-flush behavior is not present in agents-js, which does not inject a synthetic frame at stream end.

No required target infrastructure is missing for the ported behavior.


Ported from livekit/agents#6744

Original PR description

RoomIO treated the publication SID as track identity, so a replacement concrete track under the same publication was ignored. It also did not observe track_unsubscribed.

Track concrete identity and make the SDK unsubscribe and subscribe events authoritative. This avoids speculative stream recovery and follows the RTC lifecycle.

Addresses AGT-3239

@rosetta-livekit-bot
rosetta-livekit-bot Bot requested a review from a team as a code owner August 28, 2026 12:54
@changeset-bot

changeset-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9c4793c

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

This PR includes changesets to release 39 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-krisp 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-protoface 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

@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: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

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