You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Room closes after another participant joins if the agent leaves with ctx.shutdown(reason="Session ended") after a short time #3597
In our scenario, we connect another human participant to the room via an outbound call and disconnect the agent (as per this). If the agent disconnects immediately or after a short time (even 60 seconds), the call ends just as the agent disconnects.
Example code:
async def entrypoint(ctx: agents.JobContext):
await ctx.connect()
session = AgentSession(
stt=deepgram.STT(),
llm=openai.LLM(model="gpt-4o-mini"),
tts=openai.TTS(),
vad=silero.VAD.load(),
)
await session.start(
room=ctx.room,
agent=Agent(instructions="You are a helpful voice AI assistant. Your replies are relevant but brief."),
)
# Instruct the agent to speak first
await session.generate_reply()
# Add another human to replace the agent
request = CreateSIPParticipantRequest(
sip_trunk_id = "XXXXXXX",
sip_call_to = "+XXXXXXX",
room_name = ctx.room.name,
participant_identity = "another-human",
participant_name = "Another Human",
play_dialtone = True,
krisp_enabled = True,
dtmf = "XXXXXXX",
wait_until_answered = True
)
await ctx.api.sip.create_sip_participant(request)
await session.say("Thank you for using our service.", allow_interruptions=False, add_to_chat_ctx=False)
await asyncio.sleep(20)
ctx.shutdown(reason="Session ended")
In the agent's web console, we see the message could not createOffer with closed peer connection.
Strangely, if we set a sufficiently long time (await asyncio.sleep(120)), the call continues normally with human participants and without the agent.
How can it be that call retention depends on the time it takes for the agent to disconnect? Normally the call should be retained even if the agent disconnects immediately.
P.S. If there is only one participant in the room (the second participant is not added) and the agent disconnects, the room is retained.
Hi, what version of livekit-agents are you using? It might be related to a new param we introduced, delete_room_on_close. Maybe try setting it to False in RoomInputOptions
We checked with version 1.2.14. And yes, delete_room_on_close=False fixed the issue. The room is retained even if the agent disconnects immediately after another human joins.
Activity
tinalenguyen commentedon Oct 7, 2025
Hi, what version of
livekit-agentsare you using? It might be related to a new param we introduced,delete_room_on_close. Maybe try setting it toFalseinRoomInputOptionsAndhs-eff commentedon Oct 8, 2025
We checked with version 1.2.14. And yes,
delete_room_on_close=Falsefixed the issue. The room is retained even if the agent disconnects immediately after another human joins.Thanks!