gray-finland-12154
12/29/2025, 12:36 AMtall-airline-16756
12/29/2025, 12:37 AMtall-airline-16756
12/29/2025, 12:37 AMhandle = session.say("Goodbye! Thank you for calling.", allow_interruptions=False)
await handle # waits for playout
await session.shutdown()
• Example (Node):
const handle = session.say('Goodbye!', { allowInterruptions: false });
await handle.waitForPlayout();
await ctx.shutdown();
• Use tool calling only if you want the LLM to decide when to end the call (e.g., after a final confirmation). In that case create an end_call tool that:
a. Calls ctx.wait_for_playout() (or waitForPlayout() on the handle) to wait for current/queued speech.
b. Calls session shutdown.
◦ Example tool (Python):
@function_tool
async def end_call(self, ctx: RunContext):
await ctx.wait_for_playout()
await self.session.shutdown()
Key settings:
• Set allow_interruptions=False on the final message so it cannot be cut off.
• If multiple queued speech items exist, awaiting the handle or wait_for_playout() ensures all queued playout completes before shutdown.
If you want, tell me whether your code runs inside an LLM tool runner (so I can give the exact tool signature) or share which SDK/language you're using and I’ll provide a concrete snippet for your setup.
Sources: Agent speech and audio | LiveKit docs