colossal-lock-10836
08/22/2025, 3:49 PMtall-airline-16756
08/22/2025, 3:49 PMtall-airline-16756
08/22/2025, 3:50 PMctx.shutdown() method right inside the agent's entrypoint function like this:
async def entrypoint(ctx: JobContext):
# do some work
...
# disconnect from the room
ctx.shutdown(reason="Session ended")
This will disconnect only that agent, letting everyone else keep going in the room without interruption.
2. Disconnecting Everyone (End Session):
If you want to end the session for everyone, you can use the server API deleteRoom like this:
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,
))
This will send a Disconnected event to the room and remove it from the server.
If you have any questions or want to chat about a specific use case, just let me know—I'm here to help!
Sources: Job lifecycle | LiveKit Docs | Inside a session | LiveKit Docs | Agents telephony integration | LiveKit Docs