From e302891f168dc7016c3eed34fd668cde3f9c8892 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 28 Feb 2026 21:39:49 -0800 Subject: [PATCH] fix: disable SSL verify for self-signed OpenAI proxy + handle no-user-msg - Pass httpx.AsyncClient(verify=False) to OpenAI STT/TTS to support self-signed certificate on OPENAI_BASE_URL proxy - Handle generate_reply calls with no user message by falling back to system/developer instructions Co-Authored-By: Claude Opus 4.6 --- packages/services/voice-agent/src/agent.py | 13 +++++++++++++ .../services/voice-agent/src/plugins/agent_llm.py | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/packages/services/voice-agent/src/agent.py b/packages/services/voice-agent/src/agent.py index 4fce32e..3f04de2 100644 --- a/packages/services/voice-agent/src/agent.py +++ b/packages/services/voice-agent/src/agent.py @@ -137,10 +137,17 @@ async def entrypoint(ctx: JobContext) -> None: # Build STT if settings.stt_provider == "openai": from livekit.plugins import openai as openai_plugin + import httpx as _httpx + import openai as _openai + + # OPENAI_BASE_URL may use a self-signed certificate (e.g. proxy) + _http_client = _httpx.AsyncClient(verify=False) + _oai_client = _openai.AsyncOpenAI(http_client=_http_client) stt = openai_plugin.STT( model=settings.openai_stt_model, language=settings.whisper_language, + client=_oai_client, ) else: stt = LocalWhisperSTT( @@ -151,10 +158,16 @@ async def entrypoint(ctx: JobContext) -> None: # Build TTS if settings.tts_provider == "openai": from livekit.plugins import openai as openai_plugin + import httpx as _httpx + import openai as _openai + + _http_client_tts = _httpx.AsyncClient(verify=False) + _oai_client_tts = _openai.AsyncOpenAI(http_client=_http_client_tts) tts = openai_plugin.TTS( model=settings.openai_tts_model, voice=settings.openai_tts_voice, + client=_oai_client_tts, ) else: tts = LocalKokoroTTS( diff --git a/packages/services/voice-agent/src/plugins/agent_llm.py b/packages/services/voice-agent/src/plugins/agent_llm.py index cec7f92..a600068 100644 --- a/packages/services/voice-agent/src/plugins/agent_llm.py +++ b/packages/services/voice-agent/src/plugins/agent_llm.py @@ -100,6 +100,16 @@ class AgentServiceLLMStream(llm.LLMStream): user_text = item.text_content break + if not user_text: + # on_enter/generate_reply may call LLM without a user message; + # look for the developer/system instruction to use as prompt + for item in self._chat_ctx.items: + if getattr(item, "type", None) != "message": + continue + if item.role in ("developer", "system"): + user_text = item.text_content + break + if not user_text: logger.warning("No user message found in chat context") return