Fix: Map interrupted field from Gemini backend to LlmResponse#481
Fix: Map interrupted field from Gemini backend to LlmResponse#481copybara-service[bot] merged 1 commit intogoogle:mainfrom
Conversation
Summary of ChangesHello @jinnigu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug in the ADK's handling of Gemini streaming responses by ensuring that interruption signals are correctly mapped and propagated to client applications. This enhancement allows for more responsive and accurate control over audio streams based on backend signals, improving the overall user experience when dealing with interrupted LLM interactions. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly maps the interrupted field from the Gemini backend to the LlmResponse, fixing a bug where interruption signals were dropped. The change in GeminiLlmConnection is straightforward and correct. New tests have been added to cover this change, which is great. However, the new tests in GeminiLlmConnectionTest.java have a significant flaw: they duplicate the implementation logic instead of calling the method they are intended to test. I've left a detailed comment with suggestions on how to refactor the tests to properly verify the production code.
2a826e6 to
64a68e6
Compare
64a68e6 to
15b7044
Compare
Context
This PR fixes #462.
Problem
When Gemini sends an interruption signal during streaming (
{"serverContent":{"interrupted":true}}), the ADK was dropping this field and never propagating it to clients. This prevented applications from stopping audio streams immediately upon interruption.Solution
Added the missing field mapping in
GeminiLlmConnection.convertToServerResponse():Added new tests to verify interrupted field mapping for true/false/empty cases.