happy-fall-6105
03/17/2026, 11:43 AMtall-airline-16756
03/17/2026, 11:43 AMtall-airline-16756
03/17/2026, 11:44 AMclose_on_disconnect = False (in Python RoomOptions or in Node.js RoomInputOptions). This prevents the AgentSession from closing when the linked participant (the user) disconnects.
• Be aware of the room lifecycle: rooms are closed automatically after a short grace period when no non-agent participants remain (the departure_timeout, default 20 seconds). If you need the room to stay available longer, you must manage that timeout or avoid deleting the room.
• If you want explicit control, you can manually delete the room via the server API (deleteRoom) when you decide it should end.
Practical notes
• LiveKit Meet itself does not add special UI controls for this; this is handled by your backend/session configuration.
• This approach lets the agent remain active and the user rejoin the same room later, as long as the room hasn’t been closed or deleted.
If you’d like, tell me:
• Which SDK/language you’re using (Node.js or Python), and
• Whether you need the room to persist longer than the default timeout.
I can then give a short example snippet and recommended next steps.
Sources: Agent session | LiveKit Documentation | Job lifecycle | LiveKit Documentation | examples/other | livekit/livekit_composite | DeepWiki, with interactive elementshappy-fall-6105
03/17/2026, 11:48 AMtall-airline-16756
03/17/2026, 11:49 AMclose_on_disconnect is disabled so the AgentSession does not automatically close when the user disconnects.
• Do not set the room to be deleted immediately when the agent session ends (delete_room_on_close should be False) if you want explicit control over when the room is removed.
Before I give code samples: which SDK/language are you using (Node.js or Python)? Also, roughly how long do you want the room to persist (e.g., 5 minutes, 30 minutes, longer)? With that I’ll provide a concise example showing the exact field names and a short snippet you can drop into your server code.
, with interactive elementshappy-fall-6105
03/18/2026, 7:28 AMtall-airline-16756
03/18/2026, 7:28 AMempty_timeout (Python) or emptyTimeout (Node.js) / departure_timeout field on the Room creation request.
◦ Set the value in seconds to how long you want the room to remain open after all non-agent participants leave (e.g., 300 for 5 minutes).
1. Ensure agent/session options are set so the agent stays:
◦ Set close_on_disconnect = False for the AgentSession so the agent doesn’t auto-close when the user leaves.
◦ Ensure delete_room_on_close = False if you don’t want the room deleted immediately when the agent session ends.
1. Optionally, create the room server-side (recommended) so you control these settings explicitly. You can also embed room configuration into access tokens if you use auto-creation via tokens.
Example fields to set
• Python Room creation: empty_timeout=<seconds>
• Node.js Room creation: emptyTimeout: <seconds>
Once you tell me whether you want Node.js or Python, I’ll provide a concise example showing the exact API call and fields to change.
, with interactive elementshappy-fall-6105
03/18/2026, 7:42 AMtall-airline-16756
03/18/2026, 7:42 AMdeparture_timeout which is correct if your SDK's request type uses that name; some SDKs use empty_timeout / emptyTimeout. Make sure you use the exact field name on CreateRoomRequest in your SDK version.
2) Keep the agent session options set to avoid automatic closure
• close_on_disconnect=False prevents the AgentSession from closing when the linked participant disconnects.
• delete_room_on_close=False prevents the room being deleted automatically when the agent session ends.
3) Example (refined) Python structure
• This mirrors your flow and emphasizes the two pieces: create the room with an increased timeout, then start the agent session with the room options.
async def entrypoint(ctx: agents.JobContext):
await ctx.connect()
try:
# create room with longer empty/departure timeout (seconds)
await ctx.api.room.create_room(
api.CreateRoomRequest(
name=ctx.room.name,
departure_timeout=120, # or empty_timeout if your SDK uses that name
)
)
# start agent session and keep agent in room after user disconnects
await session.start(
room=ctx.room,
agent=agent_instance,
room_options=room_io.RoomOptions(
video_input=True,
audio_input=room_io.AudioInputOptions(
noise_cancellation=noise_cancellation.BVC(),
),
close_on_disconnect=False,
delete_room_on_close=False,
),
)
finally:
# optional cleanup if needed
await ctx.disconnect()
4) Practical tips
• Confirm the exact field name on CreateRoomRequest in your installed SDK (search for departure_timeout, empty_timeout, or emptyTimeout).
• If your system may create the same room name elsewhere, consider handling create-room errors (room already exists) or using an upsert pattern.
• If you need longer persistence than a few minutes, raise the timeout accordingly (value is in seconds).
• If you need explicit control to end the room earlier/later, call the server-side deleteRoom when desired.
If you tell me which exact Python LiveKit package and version you’re using (or paste the CreateRoomRequest signature), I’ll confirm the exact field name and give any tiny adjustments needed.
, with interactive elements