:dart: The Issue: LiveKit Client Version or Source...
# ask-ai
m
🎯 The Issue: LiveKit Client Version or Source Enum Mismatch The problem is that setMicrophoneEnabled(true) is setting the track source to 2, but the agent expects SOURCE_MICROPHONE. This suggests: 1. LiveKit client version mismatch - frontend and backend using different source enum values 2. Source enum mapping issue - source 2 should map to SOURCE_MICROPHONE but doesn’t
t
Thanks for reaching out, Pablo. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Just wanted to share that the
setMicrophoneEnabled
method in LiveKit always uses the
SOURCE_MICROPHONE
enum value across all SDKs, which is set to 2. This helps make sure that turning on the microphone points to the right source. If things seem off, it might be because of: • A version mismatch between your frontend and backend SDKs. Double-check that both are updated and compatible. • Any custom tweaks or overrides in your project that might be changing how the source is mapped. Could you let me know which SDK versions you’re working with on both frontend and backend? That way, I can help figure out if there’s a compatibility hiccup. Sources: livekit-rtc/livekit/rtc/_proto/track_pb2.pyi | src/room/participant/RemoteParticipant.ts | packages/livekit-rtc/src/proto/track_pb.ts | Runtime/Scripts/Proto/Track.cs | lib/src/participant/local.dart
m
i’m using node in FE and python in BE.
t
Hey there! Just wanted to share how the Node.js and Python SDKs for LiveKit handle microphone control a bit differently, but they still work well together thanks to shared protocol definitions for track sources: • Node.js SDK: You can use the
setMicrophoneEnabled
method to turn the microphone track on or off directly with
SOURCE_MICROPHONE
(which has the value 2). • Python SDK: Here, microphone control means publishing audio tracks using
TrackSource.SOURCE_MICROPHONE
or setting the audio input through the session object. Just a heads-up, make sure both SDKs are on compatible versions to keep everything running smoothly. If you’re still running into issues, could you let me know the exact versions of the Node.js and Python SDKs you’re working with? I’m happy to help figure this out together! Sources: livekit-agents/livekit/agents/voice/room_io/_output.py | Camera & microphone | LiveKit Docs | packages/livekit-rtc/src/proto/track_pb.ts | Publishing tracks | LiveKit Docs
m
The Real Issue is NOT the Source Value! The other AI is correct: • ✅ SOURCE_MICROPHONE should have value 2 • ✅ Frontend is publishing correctly with source 2 • ❌ Agent still shows participant: null despite correct source This means the issue is NOT the source enum value - it’s something else in the participant identification.
t
It sounds like the participant showing as null, even though the source value is correct, might be due to the participant’s connection status or permissions. Let’s try a few things to get to the bottom of this: • Make sure the local participant is fully connected to the room before you call
setMicrophoneEnabled(true)
. This method works best when it’s called after the connection is all set up. • Double-check that the user has granted microphone permissions. Without those, the mic just won’t work. • Take a look at any platform-specific quirks or limits in the Node.js and Python SDKs that might be causing issues with participant identification. Could you let me know if you’re calling
setMicrophoneEnabled
only after the participant has connected to the room? Also, do you see any errors or warnings in the logs while this is happening? I’m here to help you figure this out! Sources: src/room/participant/LocalParticipant.ts | components/playground.tsx | components/playground.tsx | Camera & microphone | LiveKit Docs | livekit-android-test/src/test/java/io/livekit/android/room/participant/Loca...
m
The Root Cause: AgentSession Audio Stream Creation The issue is in the AgentSession configuration. Even though we create it with: python session = AgentSession( vad=ctx.proc.userdata[“vad”], llm=google.LLM(model=“gemini-2.5-flash”), stt=stt_instance, tts=tts_instance, _turn_detection_=EnglishModel(), ) The session is not creating an audio stream (_audio_stream: False). The Fix: We need to ensure the AgentSession properly initializes its audio stream. This might require: 1. Different AgentSession parameters 2. Explicit audio stream configuration 3. Different STT/TTS initialization The participant: null happens because the input stream has no audio stream to attach to, so it defaults to null participant. This is the real root cause - not timing, not source values, but the AgentSession audio stream initialization. Review Changes 26.7% Add Context
t
It looks like the main issue is that the AgentSession isn’t initializing an audio stream because it’s missing or can’t find the participant reference. To fix this, you’ll want to make sure the AgentSession is set up with a specific participant right from the start. Here’s a friendly walkthrough on how to do that: 1. When you initialize the AgentSession, explicitly set the participant using the
RoomIO
constructor:
Copy code
session = AgentSession(llm=openai.realtime.RealtimeModel())
room_io = RoomIO(session, room=ctx.room, participant="participant-identity")
await room_io.start()
await session.start(agent=MyAgent())
The
participant
parameter is key here—it tells the agent to process audio only from that particular participant. If the participant joins after you’ve initialized the session, no worries! You can use the
set_participant()
method to assign them on the fly. Also, just double-check these points to keep everything running smoothly: • The participant identity matches someone who’s actually in the room. • The participant has their microphone track published (
track_publication.source == rtc.TrackSource.SOURCE_MICROPHONE
). • The agent is subscribed to the audio track (you can check the
subscribed
status on the
RemoteTrackPublication
). If you want, I’m here to help you walk through these steps or troubleshoot the session setup further. Just let me know! Sources: livekit-agents/livekit/agents/voice/room_io/_output.py | agents/src/multimodal/multimodal_agent.ts | How to set a fixed participant for agent audio processing