alert-continent-21953
11/03/2025, 8:46 AMtall-airline-16756
11/03/2025, 8:46 AMtall-airline-16756
11/03/2025, 8:46 AMalert-continent-21953
11/03/2025, 8:47 AMtall-airline-16756
11/03/2025, 8:47 AMdeleteRoom API to close the entire LiveKit room session. This will disconnect everyone and make sure any recordings stop smoothly. This is the best way to fully clean up the session.
• Disconnect only the agent: If you'd like to keep the session active for others, you can just disconnect the agent while letting the rest continue.
• Stop active egress (if applicable): If your session includes recording or streaming, you can manually stop these using the StopEgress API. But don’t worry—deleting the room will take care of this automatically too.
For the smoothest experience, I recommend using the deleteRoom API to make sure everything wraps up nicely and all resources are freed. If you’d like, I’m here to guide you through these steps or answer any questions you have!
Sources: Job lifecycle | LiveKit Docs | Egress examples | LiveKit docs | Agents telephony integration | LiveKit Docs | Connecting to LiveKit | LiveKit docs | Managing rooms | LiveKit docsalert-continent-21953
11/03/2025, 9:27 AMtall-airline-16756
11/03/2025, 9:28 AMdelete_room_on_close=True option within RoomInputOptions. This will take care of deleting the room automatically when the agent session ends. Here’s a quick example:
from livekit.agents.voice import RoomInputOptions
await session.start(
agent=MyAgent(),
room=ctx.room,
room_input_options=RoomInputOptions(delete_room_on_close=True),
)
• Manual Room Deletion in Shutdown Callback: Another way is to add a shutdown callback that deletes the room manually. Here’s how you can do it:
from livekit import api
@ctx.on("shutdown")
async def on_shutdown(reason: str):
await ctx.api.room.delete_room(api.DeleteRoomRequest(room=ctx.room.name))
• Using JobContext's Built-in Method: You can also use the handy ctx.delete_room() method, which includes built-in error handling. For example:
@ctx.on("shutdown")
async def on_shutdown(reason: str):
await ctx.delete_room()
In most situations, I’d suggest going with the automatic deletion option (delete_room_on_close=True) since it makes things simpler and helps ensure the room is cleaned up reliably. If you’d like, I’m here to walk you through implementing this or answer any questions you might have!
Sources: livekit-agents/livekit/agents/ipc/job_proc_lazy_main.py | telephony/sip_lifecycle.py | Managing rooms | LiveKit docsalert-continent-21953
11/03/2025, 9:31 AMDEFAULT_PARTICIPANT_KINDS."""
participant_identity: NotGivenOr[str] = NOT_GIVEN
"""The participant to link to. If not provided, link to the first participant.
Can be overridden by the participant argument of RoomIO constructor or set_participant."""
pre_connect_audio: bool = True
"""Pre-connect audio enabled or not."""
pre_connect_audio_timeout: float = 3.0
"""The pre-connect audio will be ignored if it doesn't arrive within this time."""
close_on_disconnect: bool = True
"""Close the AgentSession if the linked participant disconnects with reasons in
CLIENT_INITIATED, ROOM_DELETED, or USER_REJECTED."""
i have this options to choose in input.. which to choosetall-airline-16756
11/03/2025, 9:32 AMdelete_room_on_close option in RoomInputOptions. Just set this option to True when you start the agent session. Here’s a simple example to guide you:
from livekit.agents import RoomInputOptions
# Configure RoomInputOptions to delete room on session close
room_input_options = RoomInputOptions(
delete_room_on_close=True,
)
# Start the agent session with the configured options
await session.start(
agent=MyAgent(),
room=ctx.room,
room_input_options=room_input_options,
)
This will take care of deleting the room automatically once the session ends, helping keep everything neat and tidy. If you have any more questions or need a hand with anything else, please don’t hesitate to ask—I’m here to support you!
Sources: examples/voice_agents/multi_agent.py | Development Tools & Resources | livekit/livekit_composite | DeepWiki | agents/src/voice/room_io/room_io.ts