microscopic-airport-67304
05/15/2025, 10:44 PMtall-airline-16756
05/15/2025, 10:45 PMtall-airline-16756
05/15/2025, 10:45 PMshutdown
method is explicitly called on the JobContext. This method gracefully shuts down the job and runs all shutdown promises. Optionally, a reason for the shutdown can be provided.
• When LiveKit receives termination signals such as SIGTERM
, SIGINT
, or SIGQUIT
. If participants are connected, LiveKit enters a "draining mode" and shuts down once all participants have disconnected. Sources: JobContext | LiveKit Agents | Distributed Setup | LiveKit Docsmicroscopic-airport-67304
05/15/2025, 10:46 PMtall-airline-16756
05/15/2025, 10:46 PMshutdown
method on the JobContext
object to gracefully shut down the job. For example:
// Using the JobContext.shutdown method
ctx.shutdown(reason="Session ended")
This method disconnects the agent from the room while allowing other participants to continue. Additionally, you can add shutdown callbacks for cleanup tasks using addShutdownCallback
.
• To End the Entire Session: Use the server API's deleteRoom
method to disconnect all participants and remove the room:
// Using the LiveKit API to delete the room
const api_client = new api.LiveKitAPI(
process.env.LIVEKIT_URL,
process.env.LIVEKIT_API_KEY,
process.env.LIVEKIT_API_SECRET
);
await api_client.room.deleteRoom({
room: ctx.job.room.name
});
Let me know if you need further assistance with implementing these methods!
Sources: JobContext | LiveKit Agents | Inside a session | LiveKit Docsmicroscopic-airport-67304
05/15/2025, 10:48 PMtall-airline-16756
05/15/2025, 10:48 PMJobContext
, as it is specific to the agent. I appreciate your clarification.
Regarding the deleteRoom
method, deleting a room causes all participants to be disconnected and removes the room from the server. However, it does not explicitly initiate the shutdown of the job for agents. If you need to ensure that the agent's shutdown hooks are triggered, you would need to explicitly call the shutdown
method on the JobContext
within the agent itself.
Let me know if you need further clarification or assistance!
Sources: Managing rooms | LiveKit Docs | Inside a session | LiveKit Docs