Our chat room application will break if the LK age...
# agents
i
Our chat room application will break if the LK agent isn't connected to the room, because we're using LK Agents not so much for AI but more so for server side application logic and other functionality that requires a backend. So the problem is this: The agent will connect to a room as soon as it's created (e.g., if a user joins a room that doesn't yet exist on the LK server), and the application has full functionality. However, if at any time the room is empty (no users except the agent), the agent will disconnect from the room, and that will happen before the LK server automatically destroys the room, and if a user joins the room during that window of time, then the agent will not be dispatched and now the backend is lost and hence much of the functionality of the chat room application is broken for that user and all other users who join the room. @refined-appointment-81829 and @lively-winter-88668 or anyone, what's the best approach for our use case? (Note we have multiple static chat rooms and dynamically created chat rooms.)
r
I think you have some options. 1. Your agent can delete the room when the last non-agent participant leave the room. There is an even for participant disconnect you can monitor. 2. You can use a unique room name each time 3. If you want agent to stay in room when participant disconnects you could set
close_on_disconnect
to false https://github.com/livekit/agents/blob/main/livekit-agents/livekit/agents/voice/room_io/room_io.py#L83 4. You may also want to explore
delete_room_on_close
which Deletes the room when the AgentSession is closed, default to False https://github.com/livekit/agents/blob/main/livekit-agents/livekit/agents/voice/room_io/room_io.py#L86