@function_tool(description="End the call immediate...
# ask-ai
b
@function_tool(description="End the call immediately after a polite goodbye.") async def end_call() -> None: ctx = get_job_context() session: AgentSession = ctx.session try: await session.say("Thanks for your time—goodbye!", allow_interruptions=True) finally: await session.close() # will hang up the room is await session.close() supported?
t
Thanks for reaching out, Abhijeet. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Just a quick heads-up: the
await session.close()
method isn’t the way to end a call in LiveKit. Instead, you’ll want to use `await session.aclose()`—that’s the asynchronous method designed to close a session properly. This is the best way to wrap up your call. If you have any questions or want some examples, don’t hesitate to ask—I’m here to help! Sources: livekit-agents/livekit/agents/voice/agent_activity.py | Agents telephony integration | LiveKit Docs
b
will this also close the call?
t
Yep, calling
session.aclose()
will close the call in LiveKit by ending the session and freeing up all the resources tied to it. It’s the right way to wrap up a call through code. If you want me to explain more or share some examples, just give me a shout! Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime... | Agents Core Architecture | livekit/livekit_composite | DeepWiki | basics/exit_message.py