Hi <@U08CKJH7C12> I'm getting a TimeoutError when ...
# agents
s
Hi @refined-appointment-81829 I'm getting a TimeoutError when deploying my LiveKit agent to a GCP VM (2 vCPUs, 3.8GB RAM). The agent works fine locally but fails on the VM during inference executor initialization. Error:
Copy code
TimeoutError
File: /usr/local/lib/python3.13/site-packages/livekit/agents/ipc/supervised_proc.py, line 169
Container stats:
Copy code
CPU: 132.64% (maxing out both cores)
Memory: 276MiB / 3.821GiB (7.05%)
Agent logs:
Copy code
appuser@8b1bc5f9b849:~$ PYTHONPATH=/home/appuser python -u src/agent.py start
INFO:google_genai._api_client:The user provided project/location will take precedence over the Vertex AI API key from the environment variable.
INFO:livekit.agents:starting worker
{"message": "starting worker", "level": "INFO", "name": "livekit.agents", "version": "1.2.2", "rtc-version": "1.0.12", "timestamp": "2025-08-06T18:56:35.202302+00:00"}
INFO:livekit.agents:preloading plugins
{"message": "preloading plugins", "level": "INFO", "name": "livekit.agents", "packages": ["livekit.plugins.cartesia", "livekit.plugins.deepgram", "livekit.plugins.silero", "livekit.plugins.assemblyai", "livekit.plugins.openai", "livekit.plugins.groq", "livekit.plugins.elevenlabs", "livekit.plugins.aws", "livekit.plugins.turn_detector", "livekit.plugins.google", "livekit.plugins.anthropic", "av"], "timestamp": "2025-08-06T18:56:35.204163+00:00"}
INFO:livekit.agents:starting inference executor
{"message": "starting inference executor", "level": "INFO", "name": "livekit.agents", "timestamp": "2025-08-06T18:56:35.476252+00:00"}
INFO:livekit.agents:initializing process
{"message": "initializing process", "level": "INFO", "name": "livekit.agents", "pid": 86, "inference": true, "timestamp": "2025-08-06T18:57:04.267543+00:00"}
INFO:livekit.agents:killing process
{"message": "killing process", "level": "INFO", "name": "livekit.agents", "pid": 86, "inference": true, "timestamp": "2025-08-06T18:57:14.402054+00:00"}
ERROR:livekit.agents:worker failed
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/asyncio/tasks.py", line 507, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/livekit/agents/ipc/channel.py", line 47, in arecv_message
    return _read_message(await dplx.recv_bytes(), messages)
                         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/livekit/agents/utils/aio/duplex_unix.py", line 35, in recv_bytes
    len_bytes = await self._reader.readexactly(4)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/streams.py", line 769, in readexactly
    await self._wait_for_data('readexactly')
  File "/usr/local/lib/python3.13/asyncio/streams.py", line 539, in _wait_for_data
    await self._waiter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/livekit/agents/cli/_run.py", line 79, in _worker_run
    await worker.run()
  File "/usr/local/lib/python3.13/site-packages/livekit/agents/worker.py", line 387, in run
    await self._inference_executor.initialize()
  File "/usr/local/lib/python3.13/site-packages/livekit/agents/ipc/supervised_proc.py", line 169, in initialize
    init_res = await asyncio.wait_for(
               ^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/asyncio/tasks.py", line 506, in wait_for
    async with timeouts.timeout(timeout):
               ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/timeouts.py", line 116, in __aexit__
    raise TimeoutError from exc_val
TimeoutError
{"message": "worker failed", "level": "ERROR", "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 \"/usr/local/lib/python3.13/site-packages/livekit/agents/ipc/channel.py\", line 47, in arecv_message\n    return _read_message(await dplx.recv_bytes(), messages)\n                         ^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.13/site-packages/livekit/agents/utils/aio/duplex_unix.py\", line 35, in recv_bytes\n    len_bytes = await self._reader.readexactly(4)\n                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.13/asyncio/streams.py\", line 769, in readexactly\n    await self._wait_for_data('readexactly')\n  File \"/usr/local/lib/python3.13/asyncio/streams.py\", line 539, in _wait_for_data\n    await self._waiter\nasyncio.exceptions.CancelledError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File \"/usr/local/lib/python3.13/site-packages/livekit/agents/cli/_run.py\", line 79, in _worker_run\n    await worker.run()\n  File \"/usr/local/lib/python3.13/site-packages/livekit/agents/worker.py\", line 387, in run\n    await self._inference_executor.initialize()\n  File \"/usr/local/lib/python3.13/site-packages/livekit/agents/ipc/supervised_proc.py\", line 169, in initialize\n    init_res = await asyncio.wait_for(\n               ^^^^^^^^^^^^^^^^^^^^^^^\n    ...<2 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", "timestamp": "2025-08-06T18:57:14.409090+00:00"}
INFO:livekit.agents:draining worker
{"message": "draining worker", "level": "INFO", "name": "livekit.agents", "id": "unregistered", "timeout": 1800, "timestamp": "2025-08-06T18:57:14.436013+00:00"}
appuser@8b1bc5f9b849:~$ ad
What I've tried: - All API keys are set correctly - Network connectivity works Questions: 1. Is 2 vCPUs enough for LiveKit agent initialization? 2. How can I increase the inference executor timeout? 3. Any LiveKit config options to reduce initialization load? The agent initializes multiple AI services (STT, TTS, LLM) simultaneously and seems to timeout after 10 seconds. Should I upgrade to 4+ vCPUs or is there a configuration fix? Thanks! 🙏
f
num_idle_processes set to minimal may help
e
try setting "initialize_process_timeout" to a larger value in agent.WorkerOptions