Current Setup:
1. LiveKit SDK Versions:
• livekit==1.0.11 (core SDK)
• livekit-agents==1.1.5
• livekit-plugins-openai==1.1.5
2. Custom Configurations:
• AgentSession: Configured with allow_interruptions=True, min_interruption_duration=0.1, min_endpointing_delay=0.15
• RoomInputOptions: Using close_on_disconnect=False
• Noise Cancellation: BVC (Background Voice Cancellation) is commented out for performance
• Auto-subscribe: We connect with default auto-subscribe enabled (ctx.connect() has no parameters)
• Custom Duplicate Prevention: We've implemented extensive manual tracking of subscribed microphone tracks per participant
3. Issue Specifics:
• This happens specifically with microphone tracks (not other track types)
• The duplicates appear when:
• Moving from Home room to a roleplay room
• The user starts speaking after entering the room
• The SDK creates duplicate AudioStream._run and _ParticipantAudioInputStream._forward_task tasks
Key Observations:
The issue seems to be that when a microphone track is subscribed, the LiveKit SDK internally creates TWO instances of audio processing pipelines. This is evidenced by the double "start reading stream" messages in the logs.
The duplicate tasks only become problematic when audio data actually flows (i.e., when the user speaks), which explains why they appear "20+ seconds later" - they're created at subscription time but only become active when audio is processed.
This could be a bug in LiveKit SDK 1.0.11 or an interaction between the agents framework and the core SDK. The fact that we see exactly 2 instances suggests it might be related to how the SDK handles audio streams internally (possibly creating separate pipelines for different purposes like transcription and audio forwarding).