fix: prevent dropping grounding-only responses in BaseLlmFlow#1351
Merged
copybara-service[bot] merged 1 commit intoJul 14, 2026
Merged
Conversation
ca99713 to
20bd26a
Compare
20bd26a to
5146e5d
Compare
5146e5d to
1a62158
Compare
damianmomotgoogle
approved these changes
Jul 14, 2026
1a62158 to
4de0d8c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Problem:
ADK Java
BaseLlmFlowdrops a model response that has grounding metadata but no content, because the "skip empty response" guard inbuildPostprocessingEventsdoes not checkgroundingMetadata. adk-python keeps such responses. This is a Python-parity gap that can silently lose grounding metadata (e.g. Google Search / citation grounding) on responses that carry no other content.Solution:
Added
&& updatedResponse.groundingMetadata().isEmpty()to the skip condition inbuildPostprocessingEvents. This ensures that grounding-only response (no content) should produce one emitted event. Also added unitTesting Plan
Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes.
Unit Tests:
Added the
postprocess_onlyGroundingMetadata_returnsEventregression test inBaseLlmFlowTest.java. This test simulates a live API chunk by injecting aLlmResponsepayload containing onlyGroundingMetadata. It successfully verifies that the postprocess method emits the event (returning a list of size 1) instead of incorrectly dropping it.Checklist