Skip to content

Comments

feat: Create MultiInputStream API primitive#1036

Merged
toubatbrian merged 9 commits intomainfrom
brian/allow-user-reconnect
Feb 19, 2026
Merged

feat: Create MultiInputStream API primitive#1036
toubatbrian merged 9 commits intomainfrom
brian/allow-user-reconnect

Conversation

@toubatbrian
Copy link
Contributor

@toubatbrian toubatbrian commented Feb 7, 2026

This class could solves the issue where user want the room to stay alive event after participant disconnected and being able to pipe the audio stream from new participants.

Related PR: #1018

Summary by CodeRabbit

  • New Features

    • MultiInputStream primitive for managing multiple input streams dynamically.
    • Audio input now exposes a close operation to shut down underlying inputs.
  • Bug Fixes / Reliability

    • Improved handling of audio recorder and subscribed track lifecycle for cleaner shutdown and interception behavior.
  • Tests

    • Comprehensive tests covering MultiInputStream behavior, concurrency, edge cases, and error handling.

Open with Devin

@changeset-bot
Copy link

changeset-bot bot commented Feb 7, 2026

🦋 Changeset detected

Latest commit: cc2fcf1

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

This PR includes changesets to release 20 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-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-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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 7, 2026

📝 Walkthrough

Walkthrough

Adds a new MultiInputStream primitive that merges multiple ReadableStream inputs into a single output stream with dynamic add/remove and close semantics. Replaces previous DeferredReadableStream usage in AudioInput, RecorderIO, and ParticipantAudioInputStream to enable runtime input management.

Changes

Cohort / File(s) Summary
Changeset & Export
\.changeset/neat-parents-develop.md, agents/src/stream/index.ts
Adds a changeset entry and re-exports the new MultiInputStream from the stream module.
Core Implementation
agents/src/stream/multi_input_stream.ts
New public MultiInputStream<T> class: manages concurrent pumps from multiple ReadableStream inputs, provides addInputStream/removeInputStream/close, tracks input count and closed state, and handles error/cleanup semantics.
Tests
agents/src/stream/multi_input_stream.test.ts
Comprehensive tests validating creation, concurrent reads, dynamic add/remove, error handling, backpressure, teeing, close semantics, id uniqueness, and edge cases.
Audio Integration
agents/src/voice/io.ts, agents/src/voice/recorder_io/recorder_io.ts, agents/src/voice/room_io/_input.ts
Replaces DeferredReadableStream with MultiInputStream<AudioFrame>, updates stream getters to return multiStream.stream, wires interception via addInputStream, adds AudioInput.close() and updates participant input lifecycle (currentInputId tracking and removal on close).

Sequence Diagram

sequenceDiagram
    participant Client
    participant AudioInput
    participant MultiInputStream
    participant InputStreams as Input<br/>Streams
    participant OutputStream

    Client->>AudioInput: create AudioInput
    AudioInput->>MultiInputStream: new MultiInputStream()

    rect rgba(100,150,200,0.5)
    Client->>AudioInput: attach input source
    AudioInput->>MultiInputStream: addInputStream(source)
    MultiInputStream-->>AudioInput: input ID
    end

    rect rgba(150,100,200,0.5)
    MultiInputStream->>InputStreams: read() (concurrent pumps)
    InputStreams-->>MultiInputStream: data chunk
    MultiInputStream->>OutputStream: write(chunk)
    end

    rect rgba(100,200,150,0.5)
    Client->>AudioInput: remove/swap input
    AudioInput->>MultiInputStream: removeInputStream(id)
    MultiInputStream->>MultiInputStream: cancel pump / release reader
    end

    rect rgba(200,150,100,0.5)
    Client->>AudioInput: close
    AudioInput->>MultiInputStream: close()
    MultiInputStream->>MultiInputStream: detach inputs / await pumps
    MultiInputStream->>OutputStream: close writer
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • rektdeckard
  • lukasIO
  • 1egoman

Poem

🐰
Streams I tend and streams I sow,
Many inputs, one soft flow,
Add, remove—I'll let them play,
Pumps hum gently through the day,
Close with care, then hop away.

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description is vague and lacks structured information required by the template, making it difficult to fully assess the scope and quality of changes. Fill out the complete PR template including explicit 'Changes Made', 'Pre-Review Checklist', 'Testing', and 'Additional Notes' sections with detailed information about modifications to AudioInput, RecorderIO, and ParticipantAudioInputStream.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: Create MultiInputStream API primitive' directly and clearly summarizes the main change—introducing a new MultiInputStream class API.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch brian/allow-user-reconnect

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

@toubatbrian
Copy link
Contributor Author

@codex review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Copy link
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 bugs or issues to report.

Open in Devin Review

devin-ai-integration[bot]

This comment was marked as resolved.

@toubatbrian toubatbrian merged commit 008aa63 into main Feb 19, 2026
7 checks passed
@toubatbrian toubatbrian deleted the brian/allow-user-reconnect branch February 19, 2026 21:54
@github-actions github-actions bot mentioned this pull request Feb 19, 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.

2 participants