Hi LiveKit Support Team, I am encountering an issu...
# ask-ai
b
Hi LiveKit Support Team, I am encountering an issue while running the LiveKit Agent with inference locally on my Windows machine. The agent fails with IPC communication and timeout errors, but the same code works perfectly when deployed on the LiveKit server. Below are the key details: Environment Details • OS: Windows 11 (64-bit) • Python Version: 3.13.0 (inside virtual environment) • LiveKit Agents SDK: 1.2.16 • RTC Version: 1.0.17 I am attaching the error logs also , Please help me to solve this issue.
t
Thanks for reaching out, Yethu. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm sorry to hear you're facing IPC communication and timeout errors while running the LiveKit Agent locally on Windows. These issues can sometimes be related to the default job execution model and IPC configuration. On Windows, the LiveKit Agent usually defaults to
JobExecutorType.THREAD
instead of
JobExecutorType.PROCESS
to help avoid
BrokenPipeError
problems when creating new processes. To help you get past this, here are some steps you can try: • Make sure to explicitly set
job_executor_type=JobExecutorType.THREAD
in your configuration for better compatibility with Windows. • If process initialization is timing out, consider increasing the
initialize_process_timeout
parameter in
WorkerOptions
. The default is 10 seconds, but extending this can help, especially for workloads that are heavy on inference. • Turning on verbose logging can be very helpful to capture detailed info about any unresponsive job executors or delays in IPC communication. • Keep an eye on the inference process status by using the
is_alive()
method to make sure everything is running smoothly. • Also, validating IPC message integrity with structured message testing patterns can confirm that communication is reliable. If you continue to experience issues, please don’t hesitate to share the specific error logs you mentioned. I’m here to help you troubleshoot further and get this resolved! Sources: livekit-plugins/livekit-plugins-browser/src/helper_main_win.cpp | Troubleshooting Latency and Timeout Errors with Turn Detection on AWS
b
DEBUGasyncioUsing proactor: IocpProactor 2025-10-31 173623,575 - DEBUG asyncio - Using proactor: IocpProactor INFOlivekit.agentsstarting worker 2025-10-31 173623,614 - INFO livekit.agents - starting worker {"version": "1.2.16", "rtc-version": "1.0.17"} INFOlivekit.agentsstarting inference executor 2025-10-31 173623,615 - INFO livekit.agents - starting inference executor INFOlivekit.agentsinitializing process 2025-10-31 173624,678 - INFO livekit.agents - initializing process {"pid": 13760, "inference": true} 2025-10-31 173634.607 | INFO | utils.loggerconfigure global logging90 - Global logging configuration applied INFOlivekit.agentskilling process 2025-10-31 173634,681 - INFO livekit.agents - killing process {"pid": 13760, "inference": true} ERRORlivekit.agentsworker failed Traceback (most recent call last): File "C:\Python313\Lib\asyncio\tasks.py", line 507, in wait_for return await fut ^^^^^^^^^ File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\ipc\channel.py", line 47, in arecv_message return _read_message(await dplx.recv_bytes(), messages) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\utils\aio\duplex_unix.py", line 35, in recv_bytes len_bytes = await self._reader.readexactly(4) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python313\Lib\asyncio\streams.py", line 769, in readexactly await self._wait_for_data('readexactly') File "C:\Python313\Lib\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 "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\cli\_run.py", line 79, in _worker_run await worker.run() File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\worker.py", line 445, in run await self._inference_executor.initialize() File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\ipc\supervised_proc.py", line 170, in initialize init_res = await asyncio.wait_for( ^^^^^^^^^^^^^^^^^^^^^^^ ...<2 lines>... ) ^ File "C:\Python313\Lib\asyncio\tasks.py", line 506, in wait_for async with timeouts.timeout(timeout): ~~~~~~~~~~~~~~~~^^^^^^^^^ File "C:\Python313\Lib\asyncio\timeouts.py", line 116, in aexit raise TimeoutError from exc_val TimeoutError 2025-10-31 173634,682 - ERROR livekit.agents - worker failed Traceback (most recent call last): File "C:\Python313\Lib\asyncio\tasks.py", line 507, in wait_for return await fut ^^^^^^^^^ File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\ipc\channel.py", line 47, in arecv_message return _read_message(await dplx.recv_bytes(), messages) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\utils\aio\duplex_unix.py", line 35, in recv_bytes len_bytes = await self._reader.readexactly(4) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python313\Lib\asyncio\streams.py", line 769, in readexactly await self._wait_for_data('readexactly') File "C:\Python313\Lib\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 "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\cli\_run.py", line 79, in _worker_run await worker.run() File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\worker.py", line 445, in run await self._inference_executor.initialize() File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\ipc\supervised_proc.py", line 170, in initialize init_res = await asyncio.wait_for( ^^^^^^^^^^^^^^^^^^^^^^^ ...<2 lines>... ) ^ File "C:\Python313\Lib\asyncio\tasks.py", line 506, in wait_for async with timeouts.timeout(timeout): ~~~~~~~~~~~~~~~~^^^^^^^^^ File "C:\Python313\Lib\asyncio\timeouts.py", line 116, in aexit raise TimeoutError from exc_val TimeoutError ERRORlivekit.agentsError in _read_ipc_task Traceback (most recent call last): File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\utils\aio\duplex_unix.py", line 35, in recv_bytes len_bytes = await self._reader.readexactly(4) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python313\Lib\asyncio\streams.py", line 767, in readexactly raise exceptions.IncompleteReadError(incomplete, n) asyncio.exceptions.IncompleteReadError: 0 bytes read on a total of 4 expected bytes The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\utils\log.py", line 16, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\cli\watcher.py", line 120, in _read_ipc_task msg = await channel.arecv_message(self._pch, proto.IPC_MESSAGES) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\ipc\channel.py", line 47, in arecv_message return _read_message(await dplx.recv_bytes(), messages) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\utils\aio\duplex_unix.py", line 43, in recv_bytes raise DuplexClosed() from e livekit.agents.utils.aio.duplex_unix.DuplexClosed 2025-10-31 173634,707 - ERROR livekit.agents - Error in _read_ipc_task Traceback (most recent call last): File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\utils\aio\duplex_unix.py", line 35, in recv_bytes len_bytes = await self._reader.readexactly(4) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python313\Lib\asyncio\streams.py", line 767, in readexactly raise exceptions.IncompleteReadError(incomplete, n) asyncio.exceptions.IncompleteReadError: 0 bytes read on a total of 4 expected bytes The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\utils\log.py", line 16, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\cli\watcher.py", line 120, in _read_ipc_task msg = await channel.arecv_message(self._pch, proto.IPC_MESSAGES) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\ipc\channel.py", line 47, in arecv_message return _read_message(await dplx.recv_bytes(), messages) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\yethu.krishnan\OneDrive - Provana India Pvt. Ltd\Documents\Provana_Projects\ContactCenterCodeBase\cc-livekit-agent\ai-agent\.venv\Lib\site-packages\livekit\agents\utils\aio\duplex_unix.py", line 43, in recv_bytes raise DuplexClosed() from e livekit.agents.utils.aio.duplex_unix.DuplexClosed this is the log and # session_manager.py import os import datetime from livekit.agents import AgentSession , inference from livekit.plugins import azure, silero, google from utils.logger import logger from utils.async_logger import ( alog_info, alog_debug, alog_warning, alog_error, alog_exception, alog_critical, alog_info_bg, alog_warning_bg, alog_error_bg, alog_exception_bg ) from livekit.plugins.turn_detector.multilingual import MultilingualModel class SessionManager: def __init__(self, enable_transcription: bool = False): self._session = None self._session_start_time = None self._enable_transcription = enable_transcription self._transcription_service = AudioService() if enable_transcription else None @staticmethod async def create_session(voice: str = "en-US-AndrewMultilingualNeural", enable_transcription: bool = False): """Create and configure an agent session with optional transcript handling.""" await alog_info(f"Configuring Agent Session with transcription {'enabled' if enable_transcription else 'disabled'}...") try: GOOGLE_PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT") # Create session with optimized configuration for smoother audio session = AgentSession( stt=inference.STT( model="deepgram/nova-2", language="en" ), # OpenAI GPT via LiveKit Inference llm=inference.LLM( model="openai/gpt-4o-mini", ), # ElevenLabs TTS via LiveKit Inference tts=inference.TTS( model="elevenlabs/eleven_flash_v2_5", voice="ODq5zmih8GrVes37Dizd" # Your voice ID ), vad=silero.VAD.load( max_buffered_speech=300.0, # Reduced for faster response activation_threshold=0.6, # Lower threshold for better sensitivity ), turn_detection=MultilingualModel(), preemptive_generation=True, user_away_timeout=15.0, # Set user away timeout to 15 seconds ) this is the code
t
It looks like the error logs are pointing to some challenges with IPC communication and process initialization timeouts. Specifically, the
asyncio.TimeoutError
happens when the inference process doesn’t respond within the set timeout, and the
asyncio.exceptions.CancelledError
indicates that some tasks are getting cancelled because the processes aren't responding. Let’s try a few steps that might help resolve this: • Consider increasing the
initialize_process_timeout
parameter in your configuration. This gives the inference process a bit more time to start up, which is especially useful if you’re working with large models. • Make sure the
job_executor_type
is explicitly set to
JobExecutorType.THREAD
on Windows. This can help prevent
BrokenPipeError
issues. • Try enabling detailed logging to get a clearer picture of the IPC communication and process lifecycle. This extra info can be really helpful in pinpointing where the delays or failures are happening. • Double-check that your inference models and dependencies are properly installed and accessible within your virtual environment. • Also, take a look at your system’s resources—like CPU and memory usage—to see if anything might be causing delays in starting or communicating with the processes. If you’re still running into trouble after these steps, feel free to share a bit more about your system’s resource usage during the agent’s execution or any changes you’ve made to the default configuration. I’m here to help you get this sorted out! Sources: livekit-plugins/livekit-plugins-fireworksai/livekit/plugins/fireworksai/stt...
b
which model you are talking about here ?
t
Thanks for reaching out! Just to make sure I understand you correctly, are you referring to the inference models listed in your configuration, like
deepgram/nova-2
for STT,
openai/gpt-4o-mini
for LLM, or
elevenlabs/eleven_flash_v2_5
for TTS? If that’s not quite it, no worries—please let me know which model or component you have questions about, and I’ll be happy to help you out!
b
why this inference model is taking time to load ?
t
I understand that waiting for inference models to load can feel a bit slow, and I’m here to help explain why that happens and how we can make it smoother for you. Loading these models takes some time because they often need to download and set up large machine learning files before they’re ready to use. Here’s what’s going on behind the scenes: • First, the model files might need to be downloaded if they aren’t already saved on your device. For example, some models come from places like the Hugging Face Hub during setup. • Next, the model is loaded into your system’s memory, which can be a bit demanding depending on the model’s size and your computer’s performance. • Finally, the system configures settings like how many CPU threads to use, based on what resources are available. To help speed things up, here are a few friendly tips you might find useful: • You can pre-download the model files before starting your agent by running
python my_agent.py download-files
. This way, the models are ready locally, and you won’t have to wait for downloads during use. • Make sure your system has enough CPU power and memory allocated to the agent process to help it initialize faster. • If you’re working in a production environment, loading models ahead of time during deployment can really cut down on startup delays. If you’re working with custom or plugin-based models, these steps should also help make their startup smoother. Please feel free to reach out if you’d like me to walk you through any part of this—I’m happy to assist! Sources: livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | Introducing LiveKit Inference: A unified model interface for voice AI | Models | LiveKit Docs
b
To help speed things up, here are a few friendly tips you might find useful: • You can pre-download the model files before starting your agent by running
python my_agent.py download-files
. This way, the models are ready locally, and you won’t have to wait for downloads during use. I did this but after that also still same
t
I understand that even after pre-downloading the model files, the initialization might still feel a bit slow because of some runtime processes like loading the model into memory, setting up ONNX inference sessions, and configuring runtime parameters. Let’s explore a few advanced steps that could help speed things up: • ONNX Session Configuration: You can tweak session options to boost performance. For instance, try setting
intra_op_num_threads
to half the number of your CPU cores (up to a maximum of 4) and
inter_op_num_threads
to 1. • Prewarm Function: Consider implementing a prewarm function that loads the models during startup, so the first inference request doesn’t have to wait. • Hardware Optimization: Make sure your CPU and memory resources are sufficient. For production environments, it’s best to use compute-optimized instances rather than burstable ones. • Container Optimization: If you’re running this within a container, pre-loading the models during the build process can help avoid delays at runtime. Could you please share a bit about your current hardware setup, like how many CPU cores and how much RAM you have available? Also, are you running this in a containerized environment? Knowing this will help me guide you toward the best optimizations. Sources: LiveKit turn detector plugin | LiveKit Docs | pkg/agentfs/examples/node.Dockerfile | .cursor/rules/agent-core.mdc | livekit-plugins/livekit-plugins-silero/livekit/plugins/silero/onnx_model.py | External data and RAG | LiveKit Docs
b
Thank you so much , it is working now!