fix: detect tool calls in mixed content responses for GoogleGenAiChatModel - #5489
Closed
VedantMadane wants to merge 1 commit into
Closed
VedantMadane wants to merge 1 commit into
VedantMadane wants to merge 1 commit into
Conversation
…Model The allMatch check in responseCandidateToGeneration required ALL parts to be function calls, causing tool calls to be silently dropped when the model returned a mix of text/thinking parts and functionCall parts (e.g. Gemini with thinking enabled). Changed to anyMatch so function calls are detected regardless of accompanying text or thought parts. Text content from non-function-call parts is now preserved in the AssistantMessage alongside the tool calls. Closes spring-projects#5466 Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
VedantMadane
force-pushed
the
fix/google-genai-mixed-tool-calls-5466
branch
from
February 23, 2026 11:05
fb951dd to
4c6e1ab
Compare
|
this is duplication of #5468 |
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.
Summary
Fixes #5466
GoogleGenAiChatModel.responseCandidateToGenerationusedallMatchto detect function call responses, requiring all parts to be function calls. When Gemini returns a mix of text/thinking parts andfunctionCallparts (e.g. with thinking enabled), the check evaluated tofalseand tool calls were silently dropped.Changes:
allMatchtoanyMatchso function calls are detected even when mixed with text or thought partsAssistantMessagealongside the tool calls (previously, mixed responses resulted in empty content)Before (broken):
After (fixed):