what are the common issues that lets agent to disc...
# ask-ai
w
what are the common issues that lets agent to disconnect from the room after 1-2 sec of joining I checked for any conflicting audio capture and found VoiceProcessorWrapper and AudioRecorder exist but aren’t started in this flow; iOS AppDelegate.swift doesn’t set audio session. From your new log, the server is still initiating “disconnect from room” a few seconds after ActiveSpeakers fires, not due to our code path. To narrow root cause fast, can we try these targeted A/B tests? I won’t change code further without your go-ahead: • Disable agent dispatch for a test: comment out dispatchAgent in AgentCallService and connect/speak. If it stays connected, the issue is triggered by remote audio/renegotiation. • Route toggle test: remove setSpeakerphoneOn(true) (or set it to false) and retry. Some iOS devices drop when forced to speaker at capture start. • Longer mic delay: increase the post-connect delay to 1000 ms before setMicrophoneEnabled(true). • AutoSubscribe off: connect with { autoSubscribe: false }, then, after 1 s, manually subscribe to the agent’s audio when it appears. This reduces early renegotiation churn. • Identity isolation test: add a per-connection random suffix (instead of per-service) for participantIdentity to rule out any identity race across back-to-back joins. Two clarifications that will help choose which to do first: • Are any other voice screens (e.g., LiveKitVoiceChatScreen or anything using AudioRecorder) mounted when AgentCallScreen is active? • Device/route used during repro (model, iOS version, speaker/earpiece/Bluetooth)? If you want me to proceed, say which two tests you prefer first (e.g., “disable agent dispatch” + “route toggle”), and I’ll implement them and add enhanced disconnect logging so we can capture the exact reason from RoomEvent.Disconnected.
t
Thanks for reaching out, Sumiya. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm sorry to hear you're experiencing agent disconnections from a LiveKit room shortly after joining. This can be frustrating, but let's work through it together. Often, these disconnections happen due to some application-level logic or media pipeline quirks. Here are a few common areas to check that might help: • Application Timeouts: Sometimes, client-side timers disconnect the agent if it doesn’t switch to an active state (like "listening") quickly enough. It’s worth double-checking if any such timers are in place. • AudioSource Configuration: Make sure the
queue_size_ms
for audio capture is set between 1000–2000ms. This helps prevent frame capture errors that might cause disconnects. • Permissions: Double-check microphone permissions in your app settings, such as the
Info.plist
on iOS, to ensure everything’s properly authorized. • Agent Dispatch: It’s a good idea to confirm that your agent dispatch rules and the
agent_name
are correctly set up. • Network/Signaling Issues: Keep an eye out for errors like
JOIN_FAILURE
or
SIGNAL_CLOSE
in your logs, as these can point to network or token-related problems. About the tests you’re planning, here are a couple of suggestions to start with: 1. Disable agent dispatch: Try commenting out
dispatchAgent
in
AgentCallService
. This can help determine if the issue is related to remote audio or renegotiation. 2. Route toggle test: Consider removing
setSpeakerphoneOn(true)
or setting it to
false
to see if forcing speaker routing might be causing the disconnect. Also, it would be really helpful if you could confirm a few details for me: • Are there any other voice screens (like
LiveKitVoiceChatScreen
) active when you’re using
AgentCallScreen
? • What device and iOS version are you using? And which audio route (speaker, earpiece, or Bluetooth) is active when the issue happens? With this info, we can dig deeper and find a solution that works for you. Thanks for your patience—I'm here to help you through this! Sources: agent-console/lib/event-types.ts | agents/src/voice/room_io/room_io.ts | livekit-protocol/livekit/protocol/models.pyi | Connecting to LiveKit | LiveKit Docs | complex-agents/drive-thru/frontend/components/session-view.tsx