How to make an AI agent hang up a SIP call proactively

This question originally came up in our Slack community and the thread has been consolidated here for long-term reference.

We are using LiveKit for SIP calls with Exotel as our telephony provider.

We want the AI Agent to cut the call proactively when it detects the conversation is complete. We tried disconnecting the room:

self.room_ref.disconnect()

But the call keeps going and the user has to hang up manually. Our telephony provider said they didn’t receive any BYE signal from LiveKit.

How can we properly hang up the call from the agent?

Having the agent disconnect or leave the room does not hang up the call.

To hang up the call, you need to delete the room. This sends the proper BYE signal to the telephony provider.

See the documentation:

Hey guys,

Saw like 2 different ways for the Agent to hang up the call. Would appreciate views on which makes the most sense.

  1. session.shutdown()- seems to mimic the Participant disconnect flow best. _aclose_impl(USER_INITIATED) scheduled → drains pending speech → cleans up STT/TTS/LLM pipelines → emits “close” event → _on_close handler sets endreason (won’t overwrite, already set) → delete_room_on_close fires as it is set as True → deletes room → SIP call ends → shutdown_fut resolves → job runs shutdown callbacks → process exits
  2. delete_room (per the official docs) - when I get the agent to delete room, the room seems to get deleted twice sometimes. This one time, the STT pipeline did not end even though the room has been deleted and went on for 40 minutes after room deletion

Do you have logs from the agent from when this happened?

Hey this is my end call implementation. I realise in my code that this function was made to be called twice (You will see 2 logs below, one is room deleted successfully, one is room close failed). But anyway when that happens, STT pipenline did not seem to end without a room:
async def end_call(ctx: JobContext, session: AgentSession):
if ctx is None:
return

try:
await ctx.api.room.delete_room(
api.DeleteRoomRequest(
room=ctx.room.name,
)
)
logger.info(“room deleted successfully, ending call”)
except Exception as exc:
logger.warning(f"room close failed: {exc}")

I see these logs when this function is called as a tool (using deepgram which returns STT metrics every 5 sec):

{“message”: “Function tool: assistant ended call.”, “level”: “INFO”, “name”: “agent.assistant”, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:50:34.011889+00:00”}

{“message”: “STT metrics”, “level”: “INFO”, “name”: “livekit.agents”, “model_name”: “nova-3”, “model_provider”: “Deepgram”, “audio_duration”: 5.05, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:50:37.428544+00:00”}

{“message”: “TTS metrics”, “level”: “INFO”, “name”: “livekit.agents”, “model_name”: “eleven_turbo_v2_5”, “model_provider”: “ElevenLabs”, “ttfb”: 0.1338160559971584, “audio_duration”: 1.88, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:50:42.165178+00:00”}

{“message”: “STT metrics”, “level”: “INFO”, “name”: “livekit.agents”, “model_name”: “nova-3”, “model_provider”: “Deepgram”, “audio_duration”: 5.0, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:50:42.437724+00:00”}

{“message”: “STT metrics”, “level”: “INFO”, “name”: “livekit.agents”, “model_name”: “nova-3”, “model_provider”: “Deepgram”, “audio_duration”: 5.05, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:50:47.478200+00:00”}

{“message”: “TTS metrics”, “level”: “INFO”, “name”: “livekit.agents”, “model_name”: “eleven_turbo_v2_5”, “model_provider”: “ElevenLabs”, “ttfb”: 0.14492220000101952, “audio_duration”: 1.88, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:50:52.196535+00:00”}

{“message”: “STT metrics”, “level”: “INFO”, “name”: “livekit.agents”, “model_name”: “nova-3”, “model_provider”: “Deepgram”, “audio_duration”: 5.0, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:50:52.488256+00:00”}

{“message”: “STT metrics”, “level”: “INFO”, “name”: “livekit.agents”, “model_name”: “nova-3”, “model_provider”: “Deepgram”, “audio_duration”: 5.05, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:50:57.528153+00:00”}

{“message”: “_SegmentSynchronizerImpl.resume called after close”, “level”: “WARNING”, “name”: “livekit.agents”, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:51:02.064310+00:00”}

{“message”: “livekit::rtc_engine::rtc_session:1772:livekit::rtc_engine::rtc_session - connection error: could not establish publisher connection: timeout”, “level”: “ERROR”, “name”: “livekit”, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:51:23.655899+00:00”}

{“message”: “failed to publish transcription\nTraceback (most recent call last):\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/agents/voice/room_io/_output.py", line 439, in capture_text\n await self._writer.write(text)\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/rtc/data_stream.py", line 295, in write\n await self._send_chunk(chunk_msg)\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/rtc/data_stream.py", line 213, in _send_chunk\n raise ConnectionError(cb.send_stream_chunk.error)\nConnectionError: engine: connection error: could not establish publisher connection: timeout”, “level”: “WARNING”, “name”: “livekit.agents”, “exc_info”: “Traceback (most recent call last):\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/agents/voice/room_io/_output.py", line 439, in capture_text\n await self._writer.write(text)\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/rtc/data_stream.py", line 295, in write\n await self._send_chunk(chunk_msg)\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/rtc/data_stream.py", line 213, in _send_chunk\n raise ConnectionError(cb.send_stream_chunk.error)\nConnectionError: engine: connection error: could not establish publisher connection: timeout”, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:51:23.656274+00:00”}

{“message”: “failed to publish transcription\nTraceback (most recent call last):\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/agents/voice/room_io/_output.py", line 307, in _publish_transcription\n await self._room.local_participant.publish_transcription(transcription)\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/rtc/participant.py", line 285, in publish_transcription\n raise PublishTranscriptionError(cb.publish_transcription.error)\nlivekit.rtc.participant.PublishTranscriptionError: engine: connection error: could not establish publisher connection: timeout”, “level”: “WARNING”, “name”: “livekit.agents”, “exc_info”: “Traceback (most recent call last):\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/agents/voice/room_io/_output.py", line 307, in _publish_transcription\n await self._room.local_participant.publish_transcription(transcription)\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/rtc/participant.py", line 285, in publish_transcription\n raise PublishTranscriptionError(cb.publish_transcription.error)\nlivekit.rtc.participant.PublishTranscriptionError: engine: connection error: could not establish publisher connection: timeout”, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:51:23.657676+00:00”}

{“message”: “livekit::rtc_engine:773:livekit::rtc_engine - resuming connection… attempt: 0”, “level”: “ERROR”, “name”: “livekit”, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:51:23.658794+00:00”}

{“message”: “livekit::rtc_engine:775:livekit::rtc_engine - resuming connection failed: signal failure: ws failure: Connection closed normally”, “level”: “ERROR”, “name”: “livekit”, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:51:23.761995+00:00”}

{“message”: “livekit::rtc_engine:749:livekit::rtc_engine - restarting connection… attempt: 1”, “level”: “ERROR”, “name”: “livekit”, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:51:23.762232+00:00”}

{“message”: “STT metrics”, “level”: “INFO”, “name”: “livekit.agents”, “model_name”: “nova-3”, “model_provider”: “Deepgram”, “audio_duration”: 5.05, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:51:27.677795+00:00”}

{“message”: “room deleted successfully, ending call”, “level”: “INFO”, “name”: “tools.end_call”, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:51:28.684739+00:00”}

{“message”: “STT metrics”, “level”: “INFO”, “name”: “livekit.agents”, “model_name”: “nova-3”, “model_provider”: “Deepgram”, “audio_duration”: 5.0, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:51:32.688493+00:00”}

{“message”: “room close failed: TwirpError(code=not_found, message=twirp error unknown: requested room does not exist, status=404)”, “level”: “WARNING”, “name”: “tools.end_call”, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:51:33.314003+00:00”}

{“message”: “STT metrics”, “level”: “INFO”, “name”: “livekit.agents”, “model_name”: “nova-3”, “model_provider”: “Deepgram”, “audio_duration”: 5.05, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:51:37.728455+00:00”}


And then STT metrics continued every 5 sec for about 30 minutes, and finally

{“message”: “failed to recognize speech, retrying in 0.1s\nTraceback (most recent call last):\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/agents/stt/stt.py", line 317, in _main_task\n return await self._run()\n ^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 539, in _run\n task.result()\n ~~~~~~~~~~~^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/agents/utils/log.py", line 16, in async_fn_logs\n return await fn(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 507, in recv_task\n raise APIStatusError(message="deepgram connection closed unexpectedly")\nlivekit.agents._exceptions.APIStatusError: deepgram connection closed unexpectedly (status_code=-1, request_id=None, body=None, retryable=True)”, “level”: “WARNING”, “name”: “livekit.agents”, “exc_info”: “Traceback (most recent call last):\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/agents/stt/stt.py", line 317, in _main_task\n return await self._run()\n ^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 539, in _run\n task.result()\n ~~~~~~~~~~~^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/agents/utils/log.py", line 16, in async_fn_logs\n return await fn(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 507, in recv_task\n raise APIStatusError(message="deepgram connection closed unexpectedly")\nlivekit.agents._exceptions.APIStatusError: deepgram connection closed unexpectedly (status_code=-1, request_id=None, body=None, retryable=True)”, “tts”: “livekit.plugins.deepgram.stt.STT”, “attempt”: 0, “streamed”: true, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T03:20:35.057353+00:00”}

{“message”: “failed to recognize speech, retrying in 2.0s\nTraceback (most recent call last):\n File "/usr/local/lib/python3.13/asyncio/tasks.py", line 507, in wait_for\n return await fut\n ^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/client.py", line 1076, in _ws_connect\n resp = await self.request(\n ^^^^^^^^^^^^^^^^^^^\n …<11 lines>…\n )\n ^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/client.py", line 779, in _request\n resp = await handler(req)\n ^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/client.py", line 734, in _connect_and_send_request\n conn = await self._connector.connect(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n req, traces=traces, timeout=real_timeout\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 672, in connect\n proto = await self._create_connection(req, traces, timeout)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 1239, in _create_connection\n _, proto = await self._create_direct_connection(req, traces, timeout)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 1562, in _create_direct_connection\n hosts = await self._resolve_host(host, port, traces=traces)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 1178, in _resolve_host\n return await asyncio.shield(resolved_host_task)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nasyncio.exceptions.CancelledError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 586, in _connect_ws\n ws = await asyncio.wait_for(\n ^^^^^^^^^^^^^^^^^^^^^^^\n …<5 lines>…\n )\n ^\n File "/usr/local/lib/python3.13/asyncio/tasks.py", line 506, in wait_for\n async with timeouts.timeout(timeout):\n ~~~~~~~~~~~~~~~~^^^^^^^^^\n File "/usr/local/lib/python3.13/asyncio/timeouts.py", line 116, in aexit\n raise TimeoutError from exc_val\nTimeoutError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/agents/stt/stt.py", line 317, in _main_task\n return await self._run()\n ^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 522, in _run\n ws = await self._connect_ws()\n ^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 601, in _connect_ws\n raise APIConnectionError("failed to connect to deepgram") from e\nlivekit.agents._exceptions.APIConnectionError: failed to connect to deepgram (body=None, retryable=True)”, “level”: “WARNING”, “name”: “livekit.agents”, “exc_info”: “Traceback (most recent call last):\n File "/usr/local/lib/python3.13/asyncio/tasks.py", line 507, in wait_for\n return await fut\n ^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/client.py", line 1076, in _ws_connect\n resp = await self.request(\n ^^^^^^^^^^^^^^^^^^^\n …<11 lines>…\n )\n ^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/client.py", line 779, in _request\n resp = await handler(req)\n ^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/client.py", line 734, in _connect_and_send_request\n conn = await self._connector.connect(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n req, traces=traces, timeout=real_timeout\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 672, in connect\n proto = await self._create_connection(req, traces, timeout)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 1239, in _create_connection\n _, proto = await self._create_direct_connection(req, traces, timeout)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 1562, in _create_direct_connection\n hosts = await self._resolve_host(host, port, traces=traces)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 1178, in _resolve_host\n return await asyncio.shield(resolved_host_task)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nasyncio.exceptions.CancelledError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 586, in _connect_ws\n ws = await asyncio.wait_for(\n ^^^^^^^^^^^^^^^^^^^^^^^\n …<5 lines>…\n )\n ^\n File "/usr/local/lib/python3.13/asyncio/tasks.py", line 506, in wait_for\n async with timeouts.timeout(timeout):\n ~~~~~~~~~~~~~~~~^^^^^^^^^\n File "/usr/local/lib/python3.13/asyncio/timeouts.py", line 116, in aexit\n raise TimeoutError from exc_val\nTimeoutError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/agents/stt/stt.py", line 317, in _main_task\n return await self._run()\n ^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 522, in _run\n ws = await self._connect_ws()\n ^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 601, in _connect_ws\n raise APIConnectionError("failed to connect to deepgram") from e\nlivekit.agents._exceptions.APIConnectionError: failed to connect to deepgram (body=None, retryable=True)”, “tts”: “livekit.plugins.deepgram.stt.STT”, “attempt”: 1, “streamed”: true, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T03:20:45.160761+00:00”}

{“message”: “failed to recognize speech, retrying in 2.0s\nTraceback (most recent call last):\n File "/usr/local/lib/python3.13/asyncio/tasks.py", line 507, in wait_for\n return await fut\n ^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/client.py", line 1076, in _ws_connect\n resp = await self.request(\n ^^^^^^^^^^^^^^^^^^^\n …<11 lines>…\n )\n ^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/client.py", line 779, in _request\n resp = await handler(req)\n ^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/client.py", line 734, in _connect_and_send_request\n conn = await self._connector.connect(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n req, traces=traces, timeout=real_timeout\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 672, in connect\n proto = await self._create_connection(req, traces, timeout)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 1239, in _create_connection\n _, proto = await self._create_direct_connection(req, traces, timeout)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 1562, in _create_direct_connection\n hosts = await self._resolve_host(host, port, traces=traces)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 1153, in _resolve_host\n await future\nasyncio.exceptions.CancelledError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 586, in _connect_ws\n ws = await asyncio.wait_for(\n ^^^^^^^^^^^^^^^^^^^^^^^\n …<5 lines>…\n )\n ^\n File "/usr/local/lib/python3.13/asyncio/tasks.py", line 506, in wait_for\n async with timeouts.timeout(timeout):\n ~~~~~~~~~~~~~~~~^^^^^^^^^\n File "/usr/local/lib/python3.13/asyncio/timeouts.py", line 116, in aexit\n raise TimeoutError from exc_val\nTimeoutError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/agents/stt/stt.py", line 317, in _main_task\n return await self._run()\n ^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 522, in _run\n ws = await self._connect_ws()\n ^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 601, in _connect_ws\n raise APIConnectionError("failed to connect to deepgram") from e\nlivekit.agents._exceptions.APIConnectionError: failed to connect to deepgram (body=None, retryable=True)”, “level”: “WARNING”, “name”: “livekit.agents”, “exc_info”: “Traceback (most recent call last):\n File "/usr/local/lib/python3.13/asyncio/tasks.py", line 507, in wait_for\n return await fut\n ^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/client.py", line 1076, in _ws_connect\n resp = await self.request(\n ^^^^^^^^^^^^^^^^^^^\n …<11 lines>…\n )\n ^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/client.py", line 779, in _request\n resp = await handler(req)\n ^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/client.py", line 734, in _connect_and_send_request\n conn = await self._connector.connect(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n req, traces=traces, timeout=real_timeout\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 672, in connect\n proto = await self._create_connection(req, traces, timeout)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 1239, in _create_connection\n _, proto = await self._create_direct_connection(req, traces, timeout)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 1562, in _create_direct_connection\n hosts = await self._resolve_host(host, port, traces=traces)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/aiohttp/connector.py", line 1153, in _resolve_host\n await future\nasyncio.exceptions.CancelledError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 586, in _connect_ws\n ws = await asyncio.wait_for(\n ^^^^^^^^^^^^^^^^^^^^^^^\n …<5 lines>…\n )\n ^\n File "/usr/local/lib/python3.13/asyncio/tasks.py", line 506, in wait_for\n async with timeouts.timeout(timeout):\n ~~~~~~~~~~~~~~~~^^^^^^^^^\n File "/usr/local/lib/python3.13/asyncio/timeouts.py", line 116, in aexit\n raise TimeoutError from exc_val\nTimeoutError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/agents/stt/stt.py", line 317, in _main_task\n return await self._run()\n ^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 522, in _run\n ws = await self._connect_ws()\n ^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/appuser/.venv/lib/python3.13/site-packages/livekit/plugins/deepgram/stt.py", line 601, in _connect_ws\n raise APIConnectionError("failed to connect to deepgram") from e\nlivekit.agents._exceptions.APIConnectionError: failed to connect to deepgram (body=None, retryable=True)”, “tts”: “livekit.plugins.deepgram.stt.STT”, “attempt”: 2, “streamed”: true, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T03:20:57.166053+00:00”}

Also seeing these before tool call, not sure if related:{“message”:livekit::rtc_engine::rtc_session:715:livekit::rtc_engine::rtc_session - signal_event taking too much time: Answer(SessionDescription { r#type: "answer", sdp: "v=0\r\no=- 156429022821259133 1771984139 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=msid-semantic:WMS *\r\na=fingerprint:sha-256 EF:F1:27:62:FD:43:DD:9A:AC:0E:21:83:D6:0E:FD:CB:08:5B:00:45:92:9A:21:A2:E3:67:57:0B:B9:CF:4F:33\r\na=extmap-allow-mixed\r\na=group:BUNDLE 0 1 2 3\r\nm=audio 9 UDP/TLS/RTP/SAVPF 63 111 0 8\r\nc=IN IP4 0.0.0.0\r\na=setup:active\r\na=mid:0\r\na=ice-ufrag:GXOWTmspmNmnXNeY\r\na=ice-pwd:xtSaoNuHHaVMRmlkFyDIihdYcnmsJFms\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:63 red/48000/2\r\na=fmtp:63 111/111\r\na=rtpmap:111 opus/48000/2\r\na=fmtp:111 minptime=10;useinbandfec=1;usedtx=1\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=recvonly\r\na=candidate:905410782 1 udp 2130706431 4.193.232.35 56599 typ host ufrag GXOWTmspmNmnXNeY\r\na=candidate:905410782 2 udp 2130706431 4.193.232.35 56599 typ host ufrag GXOWTmspmNmnXNeY\r\na=candidate:233762139 1 udp 2130706431 172.17.0.1 58470 typ host ufrag GXOWTmspmNmnXNeY\r\na=candidate:233762139 2 udp 2130706431 172.17.0.1 58470 typ host ufrag GXOWTmspmNmnXNeY\r\na=candidate:2281965886 1 tcp 1671430143 4.193.232.35 7881 typ host tcptype passive ufrag GXOWTmspmNmnXNeY\r\na=candidate:2281965886 2 tcp 1671430143 4.193.232.35 7881 typ host tcptype passive ufrag GXOWTmspmNmnXNeY\r\na=candidate:2954730683 1 tcp 1671430143 172.17.0.1 7881 typ host tcptype passive ufrag GXOWTmspmNmnXNeY\r\na=candidate:2954730683 2 tcp 1671430143 172.17.0.1 7881 typ host tcptype passive ufrag GXOWTmspmNmnXNeY\r\na=end-of-candidates\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=setup:active\r\na=mid:1\r\na=sendrecv\r\na=sctp-port:5000\r\na=max-message-size:65535\r\na=ice-ufrag:GXOWTmspmNmnXNeY\r\na=ice-pwd:xtSaoNuHHaVMRmlkFyDIihdYcnmsJFms\r\nm=audio 9 UDP/TLS/RTP/SAVPF 63 111 0 8\r\nc=IN IP4 0.0.0.0\r\na=setup:active\r\na=mid:2\r\na=ice-ufrag:GXOWTmspmNmnXNeY\r\na=ice-pwd:xtSaoNuHHaVMRmlkFyDIihdYcnmsJFms\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:63 red/48000/2\r\na=fmtp:63 111/111\r\na=rtpmap:111 opus/48000/2\r\na=fmtp:111 minptime=10;useinbandfec=1;usedtx=1\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=recvonly\r\nm=audio 9 UDP/TLS/RTP/SAVPF 63 111 0 8\r\nc=IN IP4 0.0.0.0\r\na=setup:active\r\na=mid:3\r\na=ice-ufrag:GXOWTmspmNmnXNeY\r\na=ice-pwd:xtSaoNuHHaVMRmlkFyDIihdYcnmsJFms\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:63 red/48000/2\r\na=fmtp:63 111/111\r\na=rtpmap:111 opus/48000/2\r\na=fmtp:111 minptime=10;useinbandfec=1;usedtx=1\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=recvonly\r\n", id: 0, mid_to_track_id: {} })”, “level”: “ERROR”, “name”: “livekit”, “call_id”: “01KJ97R1DPE5PP2FYWT1F1G06Z”, “pid”: 36, “job_id”: “AJ_oHPvJPWgb8ra”, “room_id”: “RM_rE78ECz4nKXX”, “timestamp”: “2026-02-25T01:49:54.009716+00:00”}

Are you self-hosting LiveKit server? I ask because I searched for that room ID and agent job in our server logs but don’t see anything