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.
This commit is contained in:
Paul Kompfner
2025-11-05 12:02:02 -05:00
parent 84ba628dfb
commit 0f69d4aea3

View File

@@ -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.