`bypass_multi_tools_limit` on `VertexAiSearchTool` is a leaky abstraction: unexpected dependencies, silent shift from inbuilt RAG to tool calling, and prompt fragility
@llalitkumarrr ci sta già lavorando.
Dal 14/9/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
The bypass_multi_tools_limit=True flag on VertexAiSearchTool is presented as a convenient boolean toggle to allow using Vertex AI Search alongside other tools. In practice, this flag is implemented as a hidden class replacement (VertexAiSearchTool → DiscoveryEngineSearchTool) that breaks the developer experience in three major ways:
- Unexpected runtime dependency: Silently requires
google-cloud-discoveryengine(google-adk[gcp]), failing at runtime with aModuleNotFoundError. - Silent shift from inbuilt RAG to client tool calling: Transparent, citation-backed model retrieval is secretly replaced with an explicit client-side function call.
- Hardcoded tool naming and prompt fragility: The substituted tool is hardcoded as
discovery_engine_search. Because developers write instructions for their domain (e.g., "use the knowledge base"), the model naturally hallucinates callingsearch(...)instead, causing runtime crashes (ValueError: Tool 'search' not found).
This breaks the illusion that setting bypass_multi_tools_limit=True is a clean, seamless configuration switch.
Minimal Reproduction
Consider a minimal agent combining a knowledge base search with a single custom helper function:
from google.adk.agents import Agent
from google.adk.tools import VertexAiSearchTool
def get_user_tier() -> str:
"""Returns the loyalty tier of the current user."""
return "Platinum"
search_tool = VertexAiSearchTool(
data_store_id="projects/my-project/locations/global/collections/default_collection/dataStores/my-store",
max_results=10,
bypass_multi_tools_limit=True,
)
agent = Agent(
name="support_agent",
model="gemini-flash-lite-latest",
static_instruction="You are a helpful support assistant. Answer user questions using the knowledge base.",
tools=[search_tool, get_user_tier],
)
The Issues
1. Undeclared Runtime Dependency (google-adk[gcp])
When bypass_multi_tools_limit=False (or when the agent has only one tool), VertexAiSearchTool works with the base google-adk package using the Gemini API's built-in grounding (types.Tool(retrieval=...)).
However, the moment a second tool is added and bypass_multi_tools_limit=True is set, ADK's internal resolver (llm_agent.py) silently swaps VertexAiSearchTool for DiscoveryEngineSearchTool. This class imports google.cloud.discoveryengine, immediately crashing with:
ModuleNotFoundError: No module named 'google.cloud.discoveryengine'
There is no warning at agent instantiation time indicating that setting this flag requires the [gcp] extra.
2. Silent Paradigm Shift: Inbuilt RAG Grounding → Tool Calling
Developers choose VertexAiSearchTool because it integrates natively with Gemini's retrieval capability:
- Grounding happens transparently inside the model generation turn.
- The model returns grounded responses with citations and
groundingMetadata. - The model does not need to decide whether to execute a function call, construct JSON arguments, or wait for a second inference round-trip.
Flipping bypass_multi_tools_limit=True quietly transforms this into a client-side function calling tool:
- The model must now generate a structured tool call.
- A local API client executes an RPC to Discovery Engine.
- The raw JSON results are piped back into the conversation context for a second LLM turn.
This fundamental architectural shift is completely hidden behind what appears to be a minor transport flag.
3. Leaky Tool Naming & Prompt Fragility (discovery_engine_search)
In discovery_engine_search_tool.py, the substituted tool inherits from FunctionTool and registers self.discovery_engine_search:
class DiscoveryEngineSearchTool(FunctionTool):
def __init__(self, ...):
super().__init__(self.discovery_engine_search)
This creates two critical problems:
- The name cannot be customized: The function name is hardcoded to
"discovery_engine_search"with the docstring"Search through Vertex AI Search's discovery engine search API."NeitherVertexAiSearchToolnorDiscoveryEngineSearchToolaccepts anameordescriptionparameter. - The model fails to call it: Prompts written naturally (e.g. "Answer user questions using the knowledge base") give the model no reason to suspect the tool is called
discovery_engine_search. LLMs (especially lightweight models likegemini-flash-lite) guess generic names likesearch(query=...), leading directly to:ValueError: Tool 'search' not found. Available tools: discovery_engine_search, get_user_tier
To make the agent work, developers are forced to leak internal Google Cloud plumbing into user-facing prompts:
"Answer user questions using the knowledge base by calling discovery_engine_search."
Suggested Improvements
-
Allow Custom Tool Naming and Description:
IfVertexAiSearchToolis going to be transformed into a clientFunctionTool, it must acceptnameanddescriptionparameters (e.g.,name="knowledge_base_search"), forwarding them toDiscoveryEngineSearchToolso the tool declaration matches the domain instructions. -
Handle Common Name Aliases / Fuzzy Resolution:
WhenDiscoveryEngineSearchToolis the only search tool present, ADK should either registersearchas an alias or allow flexible resolution rather than failing with a hardValueError. -
Explicit Tooling over Magic Flags:
Rather than hiding a completely different execution model and dependency set behindbypass_multi_tools_limit=True, consider deprecating the flag in favor of:- Providing
DiscoveryEngineSearchTooldirectly as a first-class, documented tool when client-side search is desired. - Documenting the sub-agent pattern (
AgentTool/sub_agents) as the recommended architectural pattern when combining native search retrieval grounding with function tools.
- Providing
-
Fail Fast with Clear Dependency Errors:
Ifbypass_multi_tools_limit=Trueis used withoutgoogle-cloud-discoveryengineinstalled, raise a clear error duringAgent.__init__instructing the user to installgoogle-adk[gcp].
- Lingua principale
- Python
- Stelle
- 21.6k
- Fork
- 4k
- Merge medio
- 13h 49m
- PR unite (30g)
- 10
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di google/adk-python
-
mcp
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
google/adk-python#7217 · 2 commenti · 1 assegnatario ·
-
tools
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
google/adk-python#7206 · 1 commento · 1 assegnatario ·
-
tools
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
google/adk-python#7205 · 1 commento · 1 assegnatario ·
-
mcp
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
google/adk-python#7196 · 1 commento · 1 assegnatario ·
-
eval request clarification
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
google/adk-python#7146 · 2 commenti · 1 assegnatario ·
Tutte le issue di google/adk-python
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
use-agent-os/agent-os#3314 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
BasedHardware/omi#15662 · 1 commento ·
-
documentation help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
AiursoftWeb/AnduinOS-2#19 ·