salmon-lighter-12882
03/18/2026, 11:00 PMtall-airline-16756
03/18/2026, 11:01 PMtall-airline-16756
03/18/2026, 11:01 PMmax_duration to enforce a hard session or call length. There’s no native parameter in AgentSession or the core agent framework to set a maximum session duration.
What you can do: implement the limit in your application logic. A common pattern is to start an asynchronous timer when the session begins and, when it expires, send a final message and shut down or disconnect the room. For example (Python/asyncio):
import asyncio
# start timer for N seconds (e.g., 180 seconds)
session_timer = asyncio.create_task(asyncio.sleep(180))
# when timer completes
await session.say("Our session time is up. Thanks for joining!")
await asyncio.sleep(2.0)
ctx.shutdown("Session timer expired")
Related settings (these do not enforce a hard duration but affect lifecycle):
• user_away_timeout — time of silence before marking user as away.
• delete_room_on_close — automatically delete the room when session ends (Python).
• drain_timeout — wait time for active jobs during graceful shutdown.
Would you like:
• A complete example integrated into your existing agent code?
• Advice for a different behavior (e.g., warn users at 1 minute left, extend session on user action, or force disconnect)?
Tell me which language/framework you’re using and how you want the flow to behave (warn vs. immediate end vs. allow extension), and I’ll give a tailored snippet.
Sources: Build a salary negotiation coach with a LemonSlice avatar | LiveKit | Agent session | LiveKit Documentation | Server startup modes | LiveKit Documentation, with interactive elements