Skip to content

allow custom name/description when VertexAiSearchTool is swapped - #7121

Open
llalitkumarrr wants to merge 1 commit into
google:mainfrom
llalitkumarrr:fix-vertexsearch-discoveryengine-name-description-flexibility
Open

llalitkumarrr wants to merge 1 commit into
google:mainfrom
llalitkumarrr:fix-vertexsearch-discoveryengine-name-description-flexibility

Conversation

@llalitkumarrr

Copy link
Copy Markdown
Collaborator

fix(tools): allow custom name/description when VertexAiSearchTool is swapped

bypass_multi_tools_limit=True silently replaces VertexAiSearchTool with
DiscoveryEngineSearchTool, whose tool name is hardcoded to
discovery_engine_search. Prompts written in domain language ("use the
knowledge base") give the model no reason to guess that name, so it emits
search(...) and the run dies with ValueError: Tool 'search' not found.
The only workaround was leaking Google Cloud plumbing into user-facing
instructions.

VertexAiSearchTool and DiscoveryEngineSearchTool now accept optional name
and description, forwarded across the swap, so the advertised tool can
match the agent's domain vocabulary.

Renaming requires overriding _get_declaration(), not just setting
self.name. FunctionTool builds the declaration from self.func and
ignores self.name, while LlmRequest.append_tools advertises
declaration.name to the model but keys dispatch on tool.name. Setting
one without the other guarantees an unresolvable call. This mirrors
BaseToolset.get_tools_with_prefix, which renames the same way; the two
compose.

The overrides are held in _name_override / _description_override rather
than BaseTool.name, which always carries the vertex_ai_search
placeholder and so cannot signal whether the caller passed anything.
Forwarding tool.name directly would silently rename every existing user's
tool and replace its description with "vertex_ai_search".

Also fixes two adjacent problems at the swap site:

  • The google-cloud-discoveryengine import ran for any agent with multiple
    tools, even with the flag off. It is now scoped to the bypass branch.
  • A missing dependency surfaced as a bare ModuleNotFoundError. It now
    raises a chained ImportError naming pip install google-adk[gcp].

Behavior is unchanged when no name or description is supplied.

Fixes #7100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants