Tool use with function calling is unsupported
Title: ADK Error: Tool use with function calling is unsupported when using sub_agents with tools like google_search
Component:* Agent Development Kit (ADK)
Description:* It is currently not possible to successfully run an agent orchestration flow within the ADK where a sub_agent (invoked by a primary LlmAgent) is configured with certain built-in tools, specifically tested with google_search. Attempting this pattern consistently results in a 400 INVALID_ARGUMENT error with the message Tool use with function calling is unsupported.
Underlying Mechanism & Problem:
When an LlmAgent (acting as an orchestrator) is configured with sub_agents, the ADK framework implicitly uses a function calling mechanism to delegate tasks. The orchestrator's LLM is presented with the sub_agents as available functions/tools. When the orchestrator decides to invoke a specific sub_agent, it effectively makes an internal "function call" (similar conceptually to the transfer_to_agent function, but handled internally by the sub_agents list).
The issue arises immediately after this internal function call activates the sub_agent. If the activated sub_agent is configured with a tool like google_search and needs to use it to fulfill the request delegated to it, the underlying API rejects this sequence, returning the 400 INVALID_ARGUMENT - Tool use with function calling is unsupported error.
This indicates a conflict where the API cannot handle a state transition from being activated via function calling directly into using a built-in tool like google_search within the same interaction turn for the sub-agent.
Steps to Reproduce:*
-
Define Agents: Create at least two
LlmAgentclasses:- An
AgentOrchestratorconfigured withsub_agents. - An
AgentSearchconfigured withtools=[google_search].
from google.adk.agents.llm_agent import LlmAgent from google.adk.tools import google_search class AgentSearch(LlmAgent): def __init__(self): super().__init__( name="AgentSearch", description="Agent to answer questions using Google Search.", instruction="You're an agent that can search the internet for informatio.", model="gemini-2.0-flash-exp", tools=[google_search], ) class AgentOrchestrator(LlmAgent): def __init__(self): super().__init__( name="AgentOrchestrator", description="Agent responsible for orchestrating multiple agents", instruction="You're an agent orchestrator, you can use your agents to get to the end result and serve the user", model="gemini-1.5-pro", sub_agents=[AgentSearch(), AgentCalculation()], ) - An
Expected Behavior: The AgentOrchestrator should successfully delegate the task to the AgentSearch sub-agent via the internal function call mechanism. AgentSearch should then be able to execute its configured google_search tool, retrieve information, and formulate a response, which is then passed back through the orchestrator. Actual Behavior: The process fails when the sub-agent (AgentSearch) configured with google_search is invoked by the orchestrator. The following error is raised:
400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Tool use with function calling is unsupported', 'status': 'INVALID_ARGUMENT'}}
Motivation & Importance: In real-world agent development, it is very common to create specialized agents that use tools like google_search to perform tasks such as retrieving web data. A natural and intuitive use case is to include such an agent as a sub_agent in an orchestrated flow. The ability to use a tool like google_search inside an agent that is invoked as a sub_agent is essential for building modular, composable, and reusable agent architectures. This is a basic and expected pattern when working with tools in the ADK, and limitations here make it harder to adopt simple and effective orchestration designs.
Final Note: I would like to understand if this limitation is known or if there is any provision for allowing the use of tools such as google_search within agents used as sub_agents. If there is any recommended workaround, it would be great to receive this guidance.
Thanks, this works for me. Glad to have found the article.
### The Research Agent
research_agent = Agent(
name="research_agent",
model=Gemini(model="gemini-2.5-flash-lite", retry_options=retry_config), # --> Apply flash model for fast application and minimize token usage
description="To do the actural research and analysis for viral contents based on topic_request & content_number",
tools=[google_search ],
instruction="""
**ABOUT YOU**
You have a specialized skillset and 12 years of industry experience in social-media viral contents research.
Based on the topic {topic_request} & content number {content_number} requested by the user, perform the viral content research with the approach below:
- You must perform analysis to ensure the the content would go viral.
- The content must be engaging, viral, easy-to-read and remain relevant to the topic.
- The content should have a primary hook, not more than 60 characters.
- The content should have a line break after the hook.
- The content should have a post-hook, either supporting the hook or completely inverse of the hook to grab attention.
- The content can be controversial, sickening, thought-provoking or dividing to grab attention.
- The content should have a call to action at the end, for example to post question, to discussion audience opinion or to share with their friends.
- The content should use relevant hashtags to make the post more discoverable.
When necessary, use `google_search()` for your research.
Finaly, print out "I've done my job" then output **ONLY** the researchs text and **DON'T** add any intro, conversation and explanation in the output text.
""" ,
output_key="draft_content",
)
### The agent below use the agent on top as its AgentTool
research_coordinator = Agent(
name="research_coordinator",
model=Gemini(model="gemini-2.5-flash-lite", retry_options=retry_config),
description="To coordinate the viral content research, to understand what the user wants and to delegate the actual the actual content research to its subagent",
tools=[tool_updt_topic,
AgentTool(agent=research_agent),],
instruction="""
**ABOUT YOU**
You are a social-media viral-content research coordinator. You DO NOT perform the actual content research -> you MUST delegate the research to the subagent `research_agent`.
You MUST follow the WORKFLOW below:
**WORKFLOW**
1. Have a conversation with the user to understand the viral topic to research on (topic_request) & the number of content (content_number) to produce
-> call `tool_updt_topic` tool to update topic_request and content_number states respectively.
2. Call AgentTool `research_agent` to delegate the research.
3. Present the viral contents draft_content (from the output of `research_agent`) to the user.
""",
output_key="final_contents",
)
but its like a workaround ..correct? the core issue still remains?
Building on the workaround and answering @nextgen-user as to why it's more than a workaround: You can architect the subagent to basically execute top-to-bottom. Just place an agentHandoff back to the base agent that executes immediately after the gemini server web search is done with its thing. Basically wrapping a tool call in an agent.
correction, AgentTask is the top-to-bottom agent. just use self.complete() when done, and put the stuff in on_enter