Is there a setting to define the max agent session...
# ask-ai
t
Is there a setting to define the max agent session time? I have some calls where the participant leaves but the room never gets destroyed
t
Thanks for reaching out, Pierrick. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking whether there's a setting to enforce a maximum agent session time so rooms are automatically destroyed when a participant leaves. Short answer: There is no built-in "max agent session time" setting. Rooms can remain open if an agent, ingress/SIP, or egress session is still present, or while background workflows are finishing. What you can do: • Call the DeleteRoom API when the participant leaves to immediately end the room for everyone. • Implement application-side logic to track session duration (or detect last human participant leaving) and trigger DeleteRoom after your desired timeout. • Use unique per-session room names (timestamp or UUID) to avoid reuse and simplify lifecycle management. If you want, tell me: • whether agents or ingress/egress sessions remain after the participant leaves, • and whether you prefer an immediate delete or a delayed timeout—then I can give exact API call examples and a short implementation pattern. Sources: Quotas and limits | LiveKit docs | Rooms, participants, and tracks | LiveKit docs | Avoiding Room ID Reuse When Re-Creating Rooms With the Same Name | Managing rooms | LiveKit docs | Connecting to LiveKit | LiveKit docs
t
• Yes agent remains • and a delayed timeout would be besr
t
Thanks — since an agent stays connected and you want a delayed timeout, here's a simple, reliable pattern you can implement. 1) Listen for the participant-left webhook/event (detect last non-agent human leaving). 2) When that event occurs, start a timer for your desired delay (e.g., 5–30 minutes). 3) On timer expiry, verify room state: • Confirm only agents/ingress/egress remain (no human participants). • Confirm no active egress/ingress workflows you need to keep. 4) If checks pass, call the DeleteRoom API to destroy the room immediately. 5) Optional: cancel the timer if a human rejoins before expiry. Implementation notes: • Persist the timer state (in-memory will work for single-instance apps; use Redis or a DB for multi-instance resilience). • Log the delete attempt and failures; retry a few times if DeleteRoom fails. • Use unique per-session room names (timestamp/UUID) if you want strict one-session lifecycles. Would you like a short code example for starting the timer from a webhook handler and calling DeleteRoom in your preferred language?
t
When participant is leaving, the room gets deleted automatically, doesn't it?
t
Short answer: Not always — a room is only automatically deleted once the last non-agent (human) participant has left and no agent/ingress/egress sessions are keeping it alive. Details: • If an agent remains connected, the room will stay open even after the human participant leaves. • Active ingress (SIP/stream) or egress (recording) can also keep the room alive until those workflows finish. • There can be a short cleanup delay after a participant leaves while egress or other cleanup completes. What to do: • If you want a delayed timeout, implement the timer pattern we described: on "participant-left" detect last human leaving, start a delay, re-check room state at expiry, and call DeleteRoom if only agents/ingress/egress remain. If you’d like, I can provide a brief code example (webhook handler + DeleteRoom call) in your preferred language. Which language do you use?
t
Ok, so we're good. I'm using LiveKit with one on one (human - agent) calls. So when the caller leaves, only the agent remains
t
You're correct that in a one-on-one (human — agent) call, if the caller leaves and the agent remains the room will stay open — it is not automatically deleted in that case. What to do next (simple, reliable option): 1. On the participant-left webhook/event detect that the last human has left. 2. Start a delayed timer (e.g., 5–30 minutes). 3. On expiry, check the room: ◦ no human participants connected, and ◦ no active ingress/egress workflows you need to preserve. 1. If checks pass, call DeleteRoom to destroy the room. Cancel the timer if the human rejoins. I can provide a short code example for the webhook + timer + DeleteRoom flow in your preferred language. Which language would you like?