fix(providers/google): omit function call ID for vertex ai to prevent error 400#278
Open
eswar-7116 wants to merge 3 commits into
Open
fix(providers/google): omit function call ID for vertex ai to prevent error 400#278eswar-7116 wants to merge 3 commits into
eswar-7116 wants to merge 3 commits into
Conversation
3c4e7e3 to
f0bb8ab
Compare
f0bb8ab to
3311f59
Compare
andreynering
reviewed
Jun 9, 2026
andreynering
left a comment
Member
There was a problem hiding this comment.
Some suggestions to make the code shorter and easier to understand.
| Args: result, | ||
| }, | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| } | |
| geminiPart := &genai.Part{ | |
| FunctionCall: &genai.FunctionCall{ | |
| ID: toolCall.ToolCallID, | |
| Name: toolCall.ToolName, | |
| Args: result, | |
| }, | |
| } | |
| // Vertex breaks with a 400 if this field be present. | |
| if isVertexAI { | |
| geminiPart.FunctionCall.ID = "" | |
| } | |
| } |
Comment on lines
+520
to
+532
| var functionResponse *genai.FunctionResponse | ||
| if isVertexAI { | ||
| functionResponse = &genai.FunctionResponse{ | ||
| Response: response, | ||
| Name: toolCall.ToolName, | ||
| } | ||
| } else { | ||
| functionResponse = &genai.FunctionResponse{ | ||
| ID: result.ToolCallID, | ||
| Response: response, | ||
| Name: toolCall.ToolName, | ||
| }, | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| var functionResponse *genai.FunctionResponse | |
| if isVertexAI { | |
| functionResponse = &genai.FunctionResponse{ | |
| Response: response, | |
| Name: toolCall.ToolName, | |
| } | |
| } else { | |
| functionResponse = &genai.FunctionResponse{ | |
| ID: result.ToolCallID, | |
| Response: response, | |
| Name: toolCall.ToolName, | |
| }, | |
| } | |
| } | |
| var functionResponse &genai.FunctionResponse{ | |
| ID: result.ToolCallID, | |
| Response: response, | |
| Name: toolCall.ToolName, | |
| } | |
| // Vertex breaks with a 400 if this field be present. | |
| if isVertexAI { | |
| functionResponse.ID = "" | |
| } |
Comment on lines
+544
to
+556
| var functionResponse *genai.FunctionResponse | ||
| if isVertexAI { | ||
| functionResponse = &genai.FunctionResponse{ | ||
| Response: response, | ||
| Name: toolCall.ToolName, | ||
| } | ||
| } else { | ||
| functionResponse = &genai.FunctionResponse{ | ||
| ID: result.ToolCallID, | ||
| Response: response, | ||
| Name: toolCall.ToolName, | ||
| }, | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| var functionResponse *genai.FunctionResponse | |
| if isVertexAI { | |
| functionResponse = &genai.FunctionResponse{ | |
| Response: response, | |
| Name: toolCall.ToolName, | |
| } | |
| } else { | |
| functionResponse = &genai.FunctionResponse{ | |
| ID: result.ToolCallID, | |
| Response: response, | |
| Name: toolCall.ToolName, | |
| }, | |
| } | |
| } | |
| var functionResponse &genai.FunctionResponse{ | |
| ID: result.ToolCallID, | |
| Response: response, | |
| Name: toolCall.ToolName, | |
| } | |
| // Vertex breaks with a 400 if this field be present. | |
| if isVertexAI { | |
| functionResponse.ID = "" | |
| } | |
| } | ||
|
|
||
| systemInstructions, content, warnings := toGooglePrompt(call.Prompt) | ||
| systemInstructions, content, warnings := toGooglePrompt(call.Prompt, g.providerOptions.backend == genai.BackendVertexAI) |
Member
There was a problem hiding this comment.
Suggested change
| systemInstructions, content, warnings := toGooglePrompt(call.Prompt, g.providerOptions.backend == genai.BackendVertexAI) | |
| isVertexAI := g.providerOptions.backend == genai.BackendVertexAI | |
| systemInstructions, content, warnings := toGooglePrompt(call.Prompt, isVertexAI) |
Author
|
Thanks for the review and the suggestions @andreynering ! |
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.
Fixes #265
Summary
idas an unknown field onFunctionCallandFunctionResponseparts in multi-turn tool history. The Gemini Developer API accepts it so the fix is backend-aware rather than unconditional.toGooglePromptnow accepts anisVertexAI boolparameter and omitsIDon both structs when targeting Vertex. The field is retained for the Developer API path keeping existing cassettes valid.Tests
I don't have GCP credentials to re-record the affected Vertex cassettes so I manually removed the
idfield from the request body sections of thevertex-gemini-2-5-flashandvertex-gemini-2-5-protool cassettes. Response sections are untouched. This keeps CI from hanging on the VCR matcher without requiring live Vertex credentials.Ran
go test ./... -v -count=1and all tests pass.I have read
CONTRIBUTING.md.I have created a discussion that was approved by a maintainer (for new features).