allow custom name/description when VertexAiSearchTool is swapped - #7121
Open
llalitkumarrr wants to merge 1 commit into
Open
llalitkumarrr wants to merge 1 commit into
llalitkumarrr wants to merge 1 commit into
Conversation
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.
fix(tools): allow custom name/description when VertexAiSearchTool is swapped
bypass_multi_tools_limit=Truesilently replaces VertexAiSearchTool withDiscoveryEngineSearchTool, whose tool name is hardcoded to
discovery_engine_search. Prompts written in domain language ("use theknowledge base") give the model no reason to guess that name, so it emits
search(...)and the run dies withValueError: Tool 'search' not found.The only workaround was leaking Google Cloud plumbing into user-facing
instructions.
VertexAiSearchTool and DiscoveryEngineSearchTool now accept optional
nameand
description, forwarded across the swap, so the advertised tool canmatch the agent's domain vocabulary.
Renaming requires overriding
_get_declaration(), not just settingself.name. FunctionTool builds the declaration fromself.funcandignores
self.name, whileLlmRequest.append_toolsadvertisesdeclaration.nameto the model but keys dispatch ontool.name. Settingone without the other guarantees an unresolvable call. This mirrors
BaseToolset.get_tools_with_prefix, which renames the same way; the twocompose.
The overrides are held in
_name_override/_description_overrideratherthan
BaseTool.name, which always carries thevertex_ai_searchplaceholder and so cannot signal whether the caller passed anything.
Forwarding
tool.namedirectly would silently rename every existing user'stool and replace its description with
"vertex_ai_search".Also fixes two adjacent problems at the swap site:
google-cloud-discoveryengineimport ran for any agent with multipletools, even with the flag off. It is now scoped to the bypass branch.
ModuleNotFoundError. It nowraises a chained ImportError naming
pip install google-adk[gcp].Behavior is unchanged when no name or description is supplied.
Fixes #7100