strong-air-82340
03/31/2026, 9:17 AM14:45:55 │ ERROR │ spacy.agents.voice │ LLM node error for agent Axis Bank: failed to generate LLM completion after 4 attempts
Traceback (most recent call last):
File "/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py", line 213, in _main_task
return await self._run()
^^^^^^^^^^^^^^^^^
File "/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/plugins/openai/responses/llm.py", line 372, in _run
await self._run_impl()
File "/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/plugins/openai/responses/llm.py", line 405, in _run_impl
async for raw_event in self._llm._ws.generate_response(payload):
File "/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/plugins/openai/responses/llm.py", line 120, in generate_response
raise APIStatusError(
livekit.agents._exceptions.APIStatusError: message='OpenAI Responses WebSocket connection closed unexpectedly', status_code=1000, retryable=True, body=raw_msg.data=1000 raw_msg.extra=''
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/kietsukishima/Desktop/Limechat/spacy_server/app/services/agents/voice/_factory.py", line 731, in llm_node
async for chunk in Agent.default.llm_node(self, chat_ctx, tools, model_settings):
File "/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/voice/agent.py", line 456, in llm_node
async for chunk in stream:
File "/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py", line 375, in __anext__
raise exc # noqa: B904
^^^^^^^^^
File "/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py", line 188, in _traceable_main_task
await self._main_task()
File "/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py", line 229, in _main_task
raise APIConnectionError(
livekit.agents._exceptions.APIConnectionError: failed to generate LLM completion after 4 attempts
{"message": "Error in _llm_inference_task\nTraceback (most recent call last):\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py\", line 213, in _main_task\n return await self._run()\n ^^^^^^^^^^^^^^^^^\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/plugins/openai/responses/llm.py\", line 372, in _run\n await self._run_impl()\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/plugins/openai/responses/llm.py\", line 405, in _run_impl\n async for raw_event in self._llm._ws.generate_response(payload):\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/plugins/openai/responses/llm.py\", line 120, in generate_response\n raise APIStatusError(\nlivekit.agents._exceptions.APIStatusError: message='OpenAI Responses WebSocket connection closed unexpectedly', status_code=1000, retryable=True, body=raw_msg.data=1000 raw_msg.extra=''\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/utils/log.py\", line 17, in async_fn_logs\n return await fn(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/opentelemetry/util/_decorator.py\", line 71, in async_wrapper\n return await func(*args, **kwargs) # type: ignore\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/voice/generation.py\", line 143, in _llm_inference_task\n async for chunk in llm_node:\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/app/services/agents/voice/_factory.py\", line 731, in llm_node\n async for chunk in Agent.default.llm_node(self, chat_ctx, tools, model_settings):\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/voice/agent.py\", line 456, in llm_node\n async for chunk in stream:\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py\", line 375, in __anext__\n raise exc # noqa: B904\n ^^^^^^^^^\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py\", line 188, in _traceable_main_task\n await self._main_task()\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py\", line 229, in _main_task\n raise APIConnectionError(\nlivekit.agents._exceptions.APIConnectionError: failed to generate LLM completion after 4 attempts", "level": "ERROR", "name": "livekit.agents", "exc_info": "Traceback (most recent call last):\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py\", line 213, in _main_task\n return await self._run()\n ^^^^^^^^^^^^^^^^^\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/plugins/openai/responses/llm.py\", line 372, in _run\n await self._run_impl()\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/plugins/openai/responses/llm.py\", line 405, in _run_impl\n async for raw_event in self._llm._ws.generate_response(payload):\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/plugins/openai/responses/llm.py\", line 120, in generate_response\n raise APIStatusError(\nlivekit.agents._exceptions.APIStatusError: message='OpenAI Responses WebSocket connection closed unexpectedly', status_code=1000, retryable=True, body=raw_msg.data=1000 raw_msg.extra=''\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/utils/log.py\", line 17, in async_fn_logs\n return await fn(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/opentelemetry/util/_decorator.py\", line 71, in async_wrapper\n return await func(*args, **kwargs) # type: ignore\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/voice/generation.py\", line 143, in _llm_inference_task\n async for chunk in llm_node:\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/app/services/agents/voice/_factory.py\", line 731, in llm_node\n async for chunk in Agent.default.llm_node(self, chat_ctx, tools, model_settings):\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/voice/agent.py\", line 456, in llm_node\n async for chunk in stream:\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py\", line 375, in __anext__\n raise exc # noqa: B904\n ^^^^^^^^^\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py\", line 188, in _traceable_main_task\n await self._main_task()\n File \"/Users/kietsukishima/Desktop/Limechat/spacy_server/.venv/lib/python3.12/site-packages/livekit/agents/llm/llm.py\", line 229, in _main_task\n raise APIConnectionError(\nlivekit.agents._exceptions.APIConnectionError: failed to generate LLM completion after 4 attempts", "pid": 6
only works in return openai.responses.LLM(**llm_kwargs) i pass use_websocket = Falsetall-airline-16756
03/31/2026, 9:17 AMtall-airline-16756
03/31/2026, 9:18 AMuse_websocket=False, which indicates the problem is specifically with the WebSocket path. I’ll help you narrow this down.
To debug this quickly, please try the checks below and share the requested details if the issue persists.
1) Quick checks (try these first)
• Confirm your OpenAI API key is still valid and available to the process (same env var and value used before upgrade).
• Restart the process after the upgrade to ensure new code and env vars are loaded.
• Try from a different network (e.g., phone hotspot) to rule out a firewall/proxy blocking WebSocket traffic.
• If you’re running locally, ensure your machine allows outbound ws/wss connections (corporate VPNs or proxies often block them).
2) Collect useful diagnostic info Please reply with:
• The LiveKit package version you upgraded from and the version you upgraded to.
• The OpenAI plugin / LiveKit OpenAI-related package version if different.
• Whether the code is running locally, in a container, or in a cloud VM.
• Any proxy, VPN, or corporate firewall between your process and the internet.
• A minimal snippet showing how you instantiate the LLM (the openai.responses.LLM(**llm_kwargs) call and the llm_kwargs keys you pass, with any secrets redacted).
3) Targeted troubleshooting steps
1. Reproduce with verbose logs:
◦ Enable debug logging for the LiveKit OpenAI plugin so we can see the WebSocket handshake and close frames (if you can, start process with debug/logging set to show network events).
1. Check WebSocket handshake and close reason:
◦ Status code 1000 is a normal/clean closure code. A clean close still may come from the server or an intermediary. The logs you pasted show raw_msg.data=1000 raw_msg.extra=''. If you can capture the handshake details or full ws close frame it will help.
1. Test direct OpenAI Realtime endpoint:
◦ If possible, run a small test client that opens a WebSocket to OpenAI’s Responses/Realtime endpoint using the same env/API key to confirm the endpoint is reachable outside LiveKit code. This narrows whether it’s LiveKit code vs. network.
1. Compare behavior between versions:
◦ If you can quickly reinstall the previous LiveKit version (the one that worked) and confirm it still works, that confirms a regression or breaking change in the newer version.
1. Fallback mode:
◦ Since use_websocket=False works for you, you can temporarily keep that while we investigate. That uses non-WebSocket (HTTP or polling) paths and avoids the immediate outage.
4) What I can help with next
• If you provide the version numbers and the instantiation snippet, I can point out any config/migration changes to the OpenAI plugin or known places to look in the logs.
• If you can share additional debug log output around the WebSocket handshake/close (no API keys), I can interpret the close reason and suggest next steps.
• I can also suggest a minimal repro test you can run locally to isolate whether the issue is network or code-related.
If you prefer, paste the instantiation snippet and version numbers here and I’ll review them and give specific changes to try.
Sources: OpenAI and LiveKit partner to turn Advanced Voice into an API | LiveKit | OpenAI LLM models | LiveKit Documentation | Diagnosing Connection Errors with the Connection Test Utility | LiveKit, with interactive elementsstrong-air-82340
03/31/2026, 9:20 AMtall-airline-16756
03/31/2026, 9:21 AMuse_websocket=False).
Next steps to narrow root cause — please provide the items below so I can give concrete guidance:
1) The exact package versions for any OpenAI-related plugin you have installed (if different from livekit-agents). For example, the version of livekit-plugins-openai or any package that provides openai.responses.LLM in your environment.
2) The code snippet where you instantiate the LLM (redact secrets). Something like:
llm = openai.responses.LLM(**llm_kwargs)
and the keys in llm_kwargs (e.g., use_websocket, model name, streaming flags, timeouts).
3) Runtime environment:
• Running locally / Docker / cloud VM?
• Any proxy, VPN, corporate network, or outbound firewall?
• Python version (I can see 3.12 in earlier trace — please confirm).
4) Short repro test you can run:
• Can you try a minimal script that creates openai.responses.LLM(use_websocket=True, ...) and connects, with debug logging enabled, so we can capture the WebSocket handshake and close frames? If you can share the sanitized debug logs (no API keys), that will be most useful.
Immediate checks to try now
• Restart the process after upgrade to ensure the new packages and env vars are in effect.
• Verify the same OpenAI API key is available to the upgraded process and has not been rate-limited or restricted.
• Try from a different network (phone hotspot) to rule out a middlebox/proxy that may be closing/wrapping the WebSocket.
• Enable debug logging for the OpenAI plugin and WebSocket library so we can see the handshake, any HTTP 101 response, and the close frame contents (you already saw a close code 1000; the handshake/headers prior to that will help identify who closed it).
Why I asked for the plugin version and snippet
• The stack trace shows failure inside livekit/plugins/openai/responses/llm.py. There may have been internal changes between livekit-agents 1.4.x and 1.5.x that affect how the WebSocket is opened, headers are sent, or pings/heartbeats are handled. Seeing the exact instantiation and plugin version lets me point to likely breaking changes or required config adjustments.
If you’d like, paste the instantiation snippet and the plugin/package versions and I’ll:
• Check for known migration points between the two versions and call out likely fields that changed.
• Suggest exact logging settings and a minimal repro script you can run to capture the ws handshake/close.
• Propose a short patch or configuration change to try (if a likely mismatch appears).
You’re on the right track using use_websocket=False as a temporary fallback — that confirms the issue is specific to the WebSocket path and not general OpenAI auth/keys. Send the snippet and versions and I’ll dig in further.
, with interactive elements