From a82158045a8f3f6d4970e6c6fa60368139af0fec Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Mon, 3 Nov 2025 11:26:48 -0500 Subject: [PATCH] Fix Gemini Live session resumption. The problem was that we weren't properly ignoring send errors during reconnection. --- CHANGELOG.md | 4 +++- src/pipecat/services/google/gemini_live/llm.py | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50e17df0f..f463db2a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,8 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fixed `GeminiLiveLLMService` session resumption after a connection timeout. + - `GeminiLiveLLMService` now properly supports context-provided system - instruction and tools + instruction and tools. ## [0.0.92] - 2025-10-31 🎃 "The Haunted Edition" 👻 diff --git a/src/pipecat/services/google/gemini_live/llm.py b/src/pipecat/services/google/gemini_live/llm.py index 06f0c21da..1674758a8 100644 --- a/src/pipecat/services/google/gemini_live/llm.py +++ b/src/pipecat/services/google/gemini_live/llm.py @@ -1717,13 +1717,17 @@ class GeminiLiveLLMService(LLMService): self._session_resumption_handle = update.new_handle async def _handle_send_error(self, error: Exception): + # Ignore "expected" errors that may have occurred for messages that + # were in-flight when a disconnection occurred. + if self._disconnecting or not self._session: + return + # In server-to-server contexts, a WebSocket error should be quite rare. # Given how hard it is to recover from a send-side error with proper # state management, and that exponential backoff for retries can have # cost/stability implications for a service cluster, let's just treat a # send-side error as fatal. - if not self._disconnecting: - await self.push_error(ErrorFrame(error=f"{self} Send error: {error}", fatal=True)) + await self.push_error(ErrorFrame(error=f"{self} Send error: {error}", fatal=True)) def create_context_aggregator( self,