crooked-tiger-31253
12/19/2025, 8:52 PMtall-airline-16756
12/19/2025, 8:52 PMtall-airline-16756
12/19/2025, 8:53 PMimport asyncio
async def set_max_duration(room: rtc.Room, duration_seconds: int):
await asyncio.sleep(duration_seconds)
await room.disconnect()
# Start when session begins
asyncio.create_task(set_max_duration(ctx.room, 300)) # 5 minutes
What to consider:
• Clean up any agent/user state after disconnect if needed.
• If you need to notify participants before disconnecting, send a message/event a short time before calling disconnect().
• If you use a different runtime (Node, Go), I can provide the equivalent snippet — which language are you using? Sources: examples/voice_agents | livekit/livekit_composite | DeepWiki