dazzling-train-30986
12/09/2025, 2:37 PMtall-airline-16756
12/09/2025, 2:37 PMtall-airline-16756
12/09/2025, 2:38 PMdeparture_timeout (empty timeout) activates if an agent is still in the room.
No — departure_timeout only applies after all participants have left. If an agent remains present, the timeout is not triggered and the room stays open. To close a room while an agent is still present, you must explicitly delete the room (for example, call the DeleteRoom API).
Sources: Job lifecycle | LiveKit docsdazzling-train-30986
12/09/2025, 2:45 PMtall-airline-16756
12/09/2025, 2:45 PMdeparture_timeout (aka empty_timeout) does not activate while an agent participant remains in the room. The timeout only starts when all participants have left. If you need the room closed while an agent is still present, you must explicitly delete the room (for example, call the DeleteRoom API).dazzling-train-30986
12/09/2025, 2:46 PMtall-airline-16756
12/09/2025, 2:46 PMkind to find humans. To explicitly check for any agent participants, test whether any remote participant has kind == rtc.ParticipantKind.PARTICIPANT_KIND_AGENT.
Suggested minimal change (keeps your structure):
def on_participant_disconnected(self, p: rtc.RemoteParticipant) -> None:
# list humans
humans_left = [
rp
for rp in self.ctx.room.remote_participants.values()
if rp.kind != rtc.ParticipantKind.PARTICIPANT_KIND_AGENT
]
# check for agents
agents_present = any(
rp.kind == rtc.ParticipantKind.PARTICIPANT_KIND_AGENT
for rp in self.ctx.room.remote_participants.values()
)
print("PARTICIPANTS:", list(self.ctx.room.remote_participants.values()))
print("Agents present:", agents_present)
if not humans_left:
logger.info("Lifecycle: Candidate disconnected. Starting departure timeout.")
self.is_candidate_connected = False
self._cancel_task("candidate_inactivity_task")
# If an agent is present, departure_timeout should NOT be started.
if agents_present:
logger.info("Agent still present — not starting departure timeout.")
return
logger.info("STARTING TIME . SLEEP")
for i in range(0, 100):
print(i)
time.sleep(1)
logger.info("END TIME . SLEEP")
Notes:
• agents_present explicitly prevents starting the departure timeout when any agent remains.
• self.ctx.room.remote_participants should reflect current participants; ensure you update state on connect/disconnect events.
• If participant kind can be missing or different, add a safe check: getattr(rp, "kind", None) == ....
Would you like this adapted to use async sleep or to run the timeout in a cancellable background task?