From 0a8bcf58c4a9eaf19e0aa7a4f61d8e693395104c Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Tue, 31 Mar 2026 10:52:33 -0400 Subject: [PATCH] Register on_connection_error event handler in WebsocketLLMService --- examples/foundational/14-function-calling-openai-responses.py | 4 ++++ src/pipecat/services/llm_service.py | 1 + 2 files changed, 5 insertions(+) diff --git a/examples/foundational/14-function-calling-openai-responses.py b/examples/foundational/14-function-calling-openai-responses.py index afdb92aa8..171e7b36e 100644 --- a/examples/foundational/14-function-calling-openai-responses.py +++ b/examples/foundational/14-function-calling-openai-responses.py @@ -84,6 +84,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm.register_function("get_current_weather", fetch_weather_from_api) llm.register_function("get_restaurant_recommendation", fetch_restaurant_recommendation) + @llm.event_handler("on_connection_error") + async def on_connection_error(service, error): + logger.error(f"LLM connection error: {error}") + @llm.event_handler("on_function_calls_started") async def on_function_calls_started(service, function_calls): # Avoid appending this filler message to the LLM context — it would diff --git a/src/pipecat/services/llm_service.py b/src/pipecat/services/llm_service.py index 66736f506..1ab07f02f 100644 --- a/src/pipecat/services/llm_service.py +++ b/src/pipecat/services/llm_service.py @@ -1051,6 +1051,7 @@ class WebsocketLLMService(LLMService, WebsocketService): """ LLMService.__init__(self, **kwargs) WebsocketService.__init__(self, reconnect_on_error=reconnect_on_error, **kwargs) + self._register_event_handler("on_connection_error") # -- lifecycle ------------------------------------------------------------