acceptable-dream-85180
08/15/2025, 7:53 PMtall-airline-16756
08/15/2025, 7:53 PMtall-airline-16756
08/15/2025, 7:53 PMctx.shutdown()
method with a reason message. This way, the other participants can keep the session going without any interruption. Here’s how you can do it in Python:
async def entrypoint(ctx: JobContext):
# Do some work...
# Disconnect from the room
ctx.shutdown(reason="Session ended")
• Disconnect All Participants and Delete the Room: If you want to close things down completely, use the delete_room
method from the LiveKit API to remove the room and disconnect everyone. Here’s an example in Python:
from livekit import api
async def entrypoint(ctx: JobContext):
# Do some work...
api_client = api.LiveKitAPI(
os.getenv("LIVEKIT_URL"),
os.getenv("LIVEKIT_API_KEY"),
os.getenv("LIVEKIT_API_SECRET"),
)
await api_client.room.delete_room(api.DeleteRoomRequest(room=ctx.job.room.name))
If you have any questions or need a hand with these methods, just let me know—I’m here to help!
Sources: Managing rooms | LiveKit Docs | Anatomy of an Agent | LiveKit Docs | Job lifecycle | LiveKit Docsacceptable-dream-85180
08/15/2025, 7:58 PMtall-airline-16756
08/15/2025, 7:58 PMonEvent("response.done", (event: ResponseDoneEvent) => {
console.log("Script completed:", event);
});
• Monitoring Agent Speech Events: You can also listen for events like VPAEvent.AGENT_STOPPED_SPEAKING
to catch when the agent stops talking, which usually means the script has finished. Check this out:
if (event === VPAEvent.AGENT_STOPPED_SPEAKING) {
console.log("Script completed");
}
• RPC Playback Completion: The avatar server sends an RPC signal to the agent once the script playback wraps up, which you can use to trigger whatever you need next.
If you want me to walk you through any of these or need a hand setting them up, just let me know—I’m here to help!