From 0f69d4aea33107b86186b7640ea1cdf89ad12146 Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Wed, 5 Nov 2025 12:02:02 -0500 Subject: [PATCH] Fixed an issue where `GeminiLiveLLMService` wasn't consistent in what it would do if if it received an `LLMContextFrame` (triggered by an `LLMRunFrame`, say) and there were no user messages in the initial context: - If the context contained a system message, that message would be converted to a user message and the LLM would respond - If the system message was provided as a constructor argument, though, no user messages would be sent to the LLM, and the LLM would therefore not respond Not adding this fix to the CHANGELOG since `GeminiLiveLLMService`'s ability to properly handle context-provided tools and system instruction hasn't been published yet. --- .../services/google/gemini_live/llm.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/pipecat/services/google/gemini_live/llm.py b/src/pipecat/services/google/gemini_live/llm.py index 317ed034d..cfa0cb0a4 100644 --- a/src/pipecat/services/google/gemini_live/llm.py +++ b/src/pipecat/services/google/gemini_live/llm.py @@ -982,7 +982,24 @@ class GeminiLiveLLMService(LLMService): await self._process_completed_function_calls(send_new_results=False) # Create initial response if needed, based on conversation history - # in context + # in context. + # (If the context has no messages but we do have a system + # instruction — meaning it was provided at init time — doctor our + # context now so that we'll have something to send to the service + # to trigger a response). + messages = params["messages"] + if not messages and self._inference_on_context_initialization: + if self._system_instruction_from_init: + logger.debug( + "No messages found in initial context; seeding with system instruction to trigger bot response." + ) + self._context.add_message( + {"role": "system", "content": self._system_instruction_from_init} + ) + else: + logger.warning( + "No messages found in initial context; cannot trigger initial bot response without messages or system instruction." + ) await self._create_initial_response() else: # We got an updated context.