In a scenario where multiple agents handoff the co...
# ask-ai
f
In a scenario where multiple agents handoff the conversation to each other, do we need to make sure we terminate the previous agent? or do they get terminated automatically after the handoff?
t
Thanks for reaching out, Tarik. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey! Just so you know, you don’t have to worry about manually terminating agents after a handoff in LiveKit. The system takes care of ending the previous agent automatically when a handoff happens. Plus, agents get disconnected on their own when sessions close, making sure everything runs smoothly without any extra effort from you. Sources: Workflows | LiveKit Docs | Job lifecycle | LiveKit Docs | Inside a session | LiveKit Docs
f
The AgentSession I create will be around for a while (30 minutes)
t
When you have long-lived
AgentSession
instances, like those lasting around 30 minutes, LiveKit has some handy ways to help you manage their lifecycle smoothly: • Drain Timeout: The
drain_timeout
parameter lets your sessions wrap up gracefully. By default, it’s set to 30 minutes. • User Inactivity Handling: The
user_away_timeout
helps spot when a user’s been inactive and can close sessions after a set time. • Graceful Shutdown: If the system gets a shutdown signal, it gives your current sessions time to finish up within the
drain_timeout
. • Session Monitoring: There are tools to tidy up resources if sessions get abandoned. If you find your session needs to run longer than 30 minutes, no worries—you can tweak the
drain_timeout
or set up your own inactivity handling to fit your needs. Sources: Worker options | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_session.py | Agents Core Architecture | livekit/livekit_composite | DeepWiki