[AI] Handle GenerateContentResponse with only usageMetadata - #16171
Conversation
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 the 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 counterproductive. 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. |
Summary of ChangesThis pull request addresses a decoding issue in the Firebase AI SDK where responses containing only usage metadata were causing failures. By updating the initialization logic and improving error diagnostics, the SDK now correctly handles these response types, allowing for the successful integration of newer Gemini models in streaming scenarios. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Activity
|
There was a problem hiding this comment.
Code Review
This pull request updates GenerateContentResponse to support decoding responses that only contain usageMetadata and improves error reporting by including the response content in the error description. Additionally, integration tests have been updated to use the gemini3_1_FlashLite model. Feedback suggests adding a unit test to verify the new decoding logic and refining the error message formatting to better handle optional values and provide more accurate codingPath information.
There was a problem hiding this comment.
Code Review
This pull request updates the GenerateContentResponse decoding logic to include usageMetadata as a valid top-level key and improves error reporting by including the response content in the DecodingError description. It also updates integration tests to use the gemini3_1_FlashLite model and adds corresponding unit tests. Feedback highlights that the string interpolation of JSONValue in the error message might be difficult to read and that attempting to decode a JSONValue after accessing a keyed container may fail depending on the Decoder implementation.
There was a problem hiding this comment.
Code Review
This pull request updates the GenerateContentResponse decoding logic to include usageMetadata as a valid key and enhances error reporting by listing the keys found when decoding fails. Additionally, it updates integration tests to use the gemini3_1_FlashLite model and introduces unit tests for the new decoding scenarios. A review comment suggests sorting the keys in the error message to ensure deterministic output for better debugging.
Updated the
Decodableimplementation forGenerateContentResponseto handle cases where the only content is theusageMetadata. This sometimes occurs when streaming using Gemini 3.1 Flash Lite and may occur elsewhere.#no-changelog