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.
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:
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.