Is there documentation on when rooms close? We're ...
# cloud
f
Is there documentation on when rooms close? We're seeing some Livekit-sourced room closures that we'd ideally like to prevent.
Copy code
2025-08-27 14:06:12,749 - WARNING livekit - livekit::rtc_engine:453:livekit::rtc_engine - received session close: "signal client closed: \"stream closed\"" UnknownReason Resume {"pid": 37051, "job_id": "AJ_cxyf9JAA9b9q"}
For reference we are using the livekit agent JobContext scaffolding but not the AgentSession infra
1. LiveKit session close: By default, a room is automatically closed when the last non-agent participant leaves. Any remaining agents disconnect. You can also end the session manually.
How does LiveKit know what is an agent vs not if we aren't using the OOTB AgentSession infra? Ideally we'd like to dodge this timeout if we can.
r
Looking at
(@jobID:"AJ_cxyf9JAA9b9q") OR (@roomID:"RM_vRxhnbFveovk")
was an agent deployed to a room that did not have a participant? Looks like agent leaves because there is no non agent participants in the room.
LiveKit knows a participant is an agent because it has
agent=true
in its token
👀 1
f
Yeah, an agent deployed to the room without a participant. Can I change the timeout of the disconnect?
r
yes I forget the property. Let me look
something about empty timeout
f
Our agent can control how long they want to wait in the room for the participant, and it has tools to leave the call by themselves.
I found this but am not sure how to use it with a manual agent dispatch
r
yes, that looks right
f
So I should make the room manually and pass the config in? I'm doing this atm:
Copy code
dispatch = await lkapi.agent_dispatch.create_dispatch(
        CreateAgentDispatchRequest(
            agent_name='Orin', room=room_name, metadata=json.dumps(metadata)
        )
    )
yes text 1
r
I am only 70% sure this is going to work. I was thinking there is some logic in the agent too
😅 1
✅ 1
f
Okay so if the user joins the room first, then I should pass
empty_timeout
into their token generation step which will create the room when they join. Then when the agent joins the existing room the timeout is already set, but it also doesn't matter since the user is already in there. Otherwise, when our agent decides to manually dispatch itself into a room and wait for the user to join, we should create the room (if not exists) and set the
empty_timeout
when we create the room. Then we should dispatch the agent to the newly created room. I think that makes sense? lol
😀 1
b
session = AgentSession( llm=openai.LLM(model=LLM_MODEL_NAME), stt=openai.STT(language=VoiceConfig.language, model=STT_MODEL_NAME), tts=openai.TTS(model=VoiceConfig.tts_model, voice=VoiceConfig.agent_voice_name), vad=ctx.proc.userdata["vad"], preemptive_generation=True, user_away_timeout=30 ) @session.on("user_state_changed") def _on_user_state_changed(ev: UserStateChangedEvent): if ev.new_state == "away": logger.info("User is away, pausing session...") session.generate_reply(instructions="ask user if they are still there") I want to automatically disconnect the call if 30 second inactivity remains. Can any one help me in this
r
Just call
ctx.delete_room()
👍 1
b
@refined-appointment-81829 thanks
Hi, Currently i am using gpt4o-mini-tts and its audio output is very costly, so can anyone tell me other alternatives which can be easily integrated with livekit also cheaper. in audio output session = AgentSession( llm=openai.LLM(model=LLM_MODEL_NAME), stt=openai.STT(language=VoiceConfig.language, model=STT_MODEL_NAME), tts=openai.TTS(model="gpt-4o-mini-tts", voice=VoiceConfig.agent_voice_name), vad=ctx.proc.userdata["vad"], preemptive_generation=True, user_away_timeout=30 )