fix: preserve searchInfo in streaming generation responses#243
Conversation
Add searchInfo accumulation logic to mergeSingleResponse() for both choices format and legacy text format. SearchInfo is now stored in AccumulatedData and restored to output across all streaming chunks. Also bump version to 2.22.24 and add unit tests. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request bumps the SDK version to 2.22.24 and introduces support for accumulating and preserving searchInfo at the output level across streaming chunks in both choices and legacy text formats. It also adds a comprehensive suite of unit tests to verify this behavior. A review comment points out a redundant block of code where searchInfo is restored twice on the same output reference, which can be safely removed.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| output.setChoices(allChoices); | ||
| // Restore searchInfo at output level | ||
| AccumulatedData firstData = accumulatedData.get(0); | ||
| if (firstData != null && firstData.searchInfo != null) { | ||
| output.setSearchInfo(firstData.searchInfo); | ||
| } |
There was a problem hiding this comment.
This block is redundant because searchInfo is already restored at the output level on lines 326-330 of mergeSingleResponse(). Since output is a reference to result.getOutput(), any changes made to it are already reflected, and there is no need to restore it again here.
| output.setChoices(allChoices); | |
| // Restore searchInfo at output level | |
| AccumulatedData firstData = accumulatedData.get(0); | |
| if (firstData != null && firstData.searchInfo != null) { | |
| output.setSearchInfo(firstData.searchInfo); | |
| } | |
| output.setChoices(allChoices); |
Add searchInfo accumulation logic to mergeSingleResponse() for both choices format and legacy text format. SearchInfo is now stored in AccumulatedData and restored to output across all streaming chunks.
Also bump version to 2.22.24 and add unit tests.