purple-rainbow-1246
09/29/2025, 5:35 PMtall-airline-16756
09/29/2025, 5:35 PMtall-airline-16756
09/29/2025, 5:36 PMParticipantConnected Event: This event fires when someone joins the room. By checking if the participant's kind is ParticipantKind.AGENT, you can tell if the agent has connected. If this event doesn’t show up for the agent within a reasonable amount of time, it likely means the agent hasn’t joined yet.
• Track the Agent’s State: Using the useVoiceAssistant() hook, you can monitor the agent’s current state, such as initializing, listening, thinking, or speaking. If the state stays at connecting or initializing longer than expected, that’s a sign the agent might not be initializing properly.
• Set Up a Timeout: Consider setting a time limit, like 10 seconds. If after this time the agent is still connecting and you haven’t seen the ParticipantConnected event for the agent, you can gently notify the user about the delay.
Here’s a simple example of how you might implement this in your code:
useEffect(() => {
if (props.state === "connecting") {
timeoutRef.current = window.setTimeout(() => {
if (props.state === "connecting" && agentHasConnected.current === false) {
setShowNotification(true);
}
}, 10_000);
}
}, [props.state]);
If the agent doesn’t join, it’s a good idea to kindly inform the user with a message like "Agent did not join the room." You might also want to disconnect the room to avoid users speaking into an empty session. This way, users feel informed and supported, even when things don’t go as planned.
Sources: Docs::Agents | Web and mobile frontends | LiveKit Docs | agent-console/lib/event-definitions.tsx | complex-agents/role-playing/role_playing_frontend/components/session-view.t...