Skip to content

ADK: Root agent with sub_agents fails if sub-agents use a mix of VertexAiSearchTool and custom function tools #899

@IanAtDazed

Description

@IanAtDazed

Describe the bug
When a root_agent is configured with sub_agents, and these sub-agents utilize different types of tools (specifically, one sub-agent uses VertexAiSearchTool and another uses a custom Python async function tool), the system throws a "400 INVALID_ARGUMENT" error. The error message states: {'error': {'code': 400, 'message': 'Multiple tools are supported only when they are all search tools.', 'status': 'INVALID_ARGUMENT'}}.

This limitation prevents the hierarchical composition of agents where different specialized sub-agents might leverage different kinds of tools (e.g., a search-optimized tool vs. a custom code execution tool).

To Reproduce

  1. Create the following agent.py:
import os
import dotenv
dotenv.load_dotenv()

from google.adk.agents import Agent
from google.adk.tools import VertexAiSearchTool

faq_tool = VertexAiSearchTool(
    data_store_id=f"projects/{os.getenv("GOOGLE_CLOUD_PROJECT")}/locations/{os.getenv("FAQ_DATA_STORE_LOCATION")}/collections/default_collection/dataStores/{os.getenv("FAQ_DATA_STORE_ID")}",
    )

async def product_tool():
    """Get product details."""

    return  "You should buy our product. It's great!"

faq_agent = Agent(
    model="gemini-2.0-flash-001",
    name='faq_agent',
    description="Handles questions about the business.",
    instruction="""Your job is to answer questions about the business.
    Use the the `faq_tool` to respond to questions.
    """,
    tools=[
        faq_tool,
    ]
)

product_agent = Agent(
    model="gemini-2.0-flash-001",
    name='product_agent',
    description="Handles questions about products.",
    instruction="""Your job is to answer questions about products.
    Use the the `product_tool` to respond to questions.
    """,
    tools=[
        product_tool,
    ]
)

root_agent = Agent(
    model="gemini-2.0-flash-001",
    name='root_agent',
    description="The main coordinator agent. Delegates tasks to sub-agents based on the user's query.",
    instruction="""You are a friendly agent coordinating a team
    
    Your primary responsibility is to delegate tasks to the appropriate sub-agents.
    You have specialized sub-agents:
    1. 'faq_agent': Handles questions about the business.
    2. 'product_agent': Handles questions about products.
    Analyze the user's query. If it's related to the business, delegate to 'faq_agent'. If it's about products, delegate to 'product_agent'.
    For anything else, respond appropriately or state you cannot handle it.
    """,
    sub_agents=[
        faq_agent,
        product_agent,
    ]
)
  1. Run adk web and ask a question about the business or a product.
  2. See error:
    The program will raise an error, and the output will contain:
{"error": "400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Multiple tools are supported only when they are all search tools.', 'status': 'INVALID_ARGUMENT'}}"}

Expected behavior
The root_agent should initialize successfully and be able to delegate tasks to faq_agent (using VertexAiSearchTool) and product_agent (using the custom product_tool) based on the user's query and the agents' descriptions/instructions. The system should support this mixed-tool type hierarchy for sub-agents.

The ability to mix tool types across sub-agents is crucial for building sophisticated, modular agent systems where different sub-agents are specialized with the most appropriate tools for their tasks.

Desktop (please complete the following information):

  • OS: Linux Mint 22
  • Python version(python -V): 3.12.0
  • ADK version(pip show google-adk): 0.5.0

Additional context

This works:

from google.adk.agents import Agent

async def faq_tool():
    """Answer a question about the business."""

    return  "This is a great business. Find out more about us at www.example.com."

async def product_tool():
    """Get product details."""

    return  "You should buy our product. It's great!"

faq_agent = Agent(
    model="gemini-2.0-flash-001",
    name='faq_agent',
    description="Handles questions about the business.",
    instruction="""Your job is to answer questions about the business.
    Use the the `faq_tool` to respond to questions.
    """,
    tools=[
        faq_tool,
    ]
)

product_agent = Agent(
    model="gemini-2.0-flash-001",
    name='product_agent',
    description="Handles questions about products.",
    instruction="""Your job is to answer questions about products.
    Use the the `product_tool` to respond to questions.
    """,
    tools=[
        product_tool,
    ]
)

root_agent = Agent(
    model="gemini-2.0-flash-001",
    name='root_agent',
    description="The main coordinator agent. Delegates tasks to sub-agents based on the user's query.",
    instruction="""You are a friendly agent coordinating a team
    
    Your primary responsibility is to delegate tasks to the appropriate sub-agents.
    You have specialized sub-agents:
    1. 'faq_agent': Handles questions about the business.
    2. 'product_agent': Handles questions about products.
    Analyze the user's query. If it's related to the business, delegate to 'faq_agent'. If it's about products, delegate to 'product_agent'.
    For anything else, respond appropriately or state you cannot handle it.
    """,
    sub_agents=[
        faq_agent,
        product_agent,
    ]
)

And this works:

from google.adk.tools import VertexAiSearchTool
from google.adk.agents import Agent
import os
import dotenv
dotenv.load_dotenv()


faq_tool = VertexAiSearchTool(
    data_store_id=f"projects/{os.getenv("GOOGLE_CLOUD_PROJECT")}/locations/{os.getenv("FAQ_DATA_STORE_LOCATION")}/collections/default_collection/dataStores/{os.getenv("FAQ_DATA_STORE_ID")}",
)

root_agent = Agent(
    model="gemini-2.0-flash-001",
    name='faq_agent',
    description="Handles questions about the business.",
    instruction="""Your job is to answer questions about the business.
    Use the the `faq_tool` to respond to questions.
    """,
    tools=[
        faq_tool,
    ]
)

At this stage, even a workaround would be greatly appreciated.

Thanks

I

Metadata

Metadata

Assignees

Labels

core[Component] This issue is related to the core interface and implementation

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions