-
Notifications
You must be signed in to change notification settings - Fork 569
feat: add gemini_tools field to GeminiModel with validation and tests #1050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add gemini_tools field to GeminiModel with validation and tests #1050
Conversation
Add support for Gemini-specific tools like GoogleSearch and CodeExecution, with validation to prevent FunctionDeclarations and comprehensive test coverage.
Co-authored-by: Copilot <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
What is the status on this |
|
I resolved conflict. |
|
Curious if we'll get this merged? |
|
Hi @zastrowm |
(editor note: I modified the PR description a bit and included this more prominently) Discussed with @dbschmigelski offline regarding this limitation. We think this makes sense for now - we'd rather index on unblocking customers in the short term and find a way in the future to represent server-side tool calls in history in the future - but we think that will require design work and normalization across providers. |
|
Thanks for the contribution @pshiko and sorry for the delay. |
Add support for Gemini-specific tools like GoogleSearch and CodeExecution, with validation to prevent FunctionDeclarations and comprehensive test coverage.
Description
Background:
Gemini API provides powerful built-in tools that are distinct from standard
FunctionDeclaration-based tools. These tools are defined in separate fields within the Gemini API'sTooltype (see https://ai.google.dev/api/caching#Tool). The existing Strands tool interface is designed around standard function declarations and cannot accommodate these Gemini-specific capabilities.Solution:
This PR implements support for Gemini's built-in tools by adding a new
gemini_toolsfield toGeminiConfig. This approach was chosen over alternatives (modifying coreToolSpecinterface or using magic string transformations) because it:genai.types.Tooldirectly)Implementation Details:
New Configuration Field:
Validation Function: Added
_validate_gemini_tools()to ensuregemini_toolsdoesn't containFunctionDeclarations(which should use the standard tools interface):Tool Merging:: Updated
_format_request_tools()to combine standard function declarations with Gemini-specific toolsExample Usage:
Limitation
No Tool Usage History: Due to the fundamental differences in how Gemini's built-in tools operate (server-side execution without explicit tool call/result blocks), we don't implement history tracking for
gemini_tools- that would require additional design work and a longer discussion on how to normalize this across all model providers. This PR is scoped down to specifically just enabling server side tools to unblock gemini customersRelated Issues
#1049
Documentation PR
Type of Change
New feature
Breaking change
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.