feat(providers/google): Add codeExecution provider tool support#7608
Merged
lgrammel merged 5 commits intovercel:mainfrom Jul 30, 2025
Merged
Conversation
4 tasks
lgrammel
reviewed
Jul 29, 2025
Comment on lines
232
to
238
| toolCallId: ( | ||
| [...content] | ||
| .reverse() | ||
| .find( | ||
| c => c.type === 'tool-call' && c.toolName === 'code_execution', | ||
| ) as any | ||
| )?.toolCallId, |
Collaborator
There was a problem hiding this comment.
it might be easier to keep the last code execution tool call id in a variable
lgrammel
reviewed
Jul 29, 2025
| if ('executableCode' in part && part.executableCode?.code) { | ||
| content.push({ | ||
| type: 'tool-call', | ||
| toolCallId: this.config.generateId(), // Generate a unique ID |
lgrammel
reviewed
Jul 29, 2025
| 'codeExecutionResult' in part && | ||
| part.codeExecutionResult | ||
| ) { | ||
| const toolCallId = pendingCodeExecutionToolCallIds.shift(); |
Collaborator
There was a problem hiding this comment.
same as above, keep id variable. what benefit does the shift logic have here (in practice)?
Contributor
Author
There was a problem hiding this comment.
In this case I was thinking of parallel calls, but I suppose I could just track the one
lgrammel
approved these changes
Jul 30, 2025
Collaborator
|
Great work @Und3rf10w thank you!! |
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.
Background
This change was necessary to add support for the Code Execution feature available in Google's Gemini models. This allows the model to generate and execute Python code to perform calculations and solve problems, enhancing its capabilities.
Summary
codeExecutiontool:google.tools.codeExecution(), is now available. This enables models that support it to run Python code.Verification
I manually verified the changes by setting up the new examples for Google Vertex AI. I ran both the
generate-text/google-vertex-code-execution.tsandstream-text/google-vertex-code-execution.tsexamples against thegemini-2.5-pro model.In both cases, the model successfully used the code execution tool to first calculate the 20th Fibonacci number and then find the nearest palindrome. The console output correctly displayed the tool calls and their corresponding results, followed by the final generated text, confirming that the end-to-end flow is working as expected.
Tasks
pnpm changesetin the project root)pnpm prettier-fixin the project root)Future Work
Related Issues
Closes #3205
Closes #6354
Closes #6365