Repository navigation
Feature Request: Native RouterAgent (Tool-Calling Orchestrator) to replace JSON-parsing boilerplate #5032
Description
Is your feature request related to a problem? Please describe.
Currently in ADK, when developers need to conditionally route a user's prompt to different specialist agents (the Router Pattern), they are forced to write messy, error-prone Python wrapper functions.
To achieve this right now, developers must:
- Instruct a
classifier_agentto output strict JSON. - Manually capture the output and write
try-except json.JSONDecodeErrorblocks. - Write hardcoded Python
if-elif-elsestatements to manually invoke the next agent in the sequence.
This leads to brittle code and misses out on ADK's native BaseAgent telemetry, suspending features, and stream graph continuity.
Describe the solution you'd like
I propose adding a native RouterAgent (inheriting from BaseAgent) directly to the google.adk.agents module, living alongside SequentialAgent and ParallelAgent.
From a developer API perspective, it would look as clean as this:
from google.adk.agents.router_agent import RouterAgent
router = RouterAgent(
name="my_router",
classifier_agent_name="classifier",
routing_key="output_type",
routes={
"A": "diet_specialist",
"B": "habitat_specialist"
},
sub_agents=[classifier, diet_specialist, habitat_specialist]
)
# Execution happens natively: Agent 1 -> (Router transparently parses) -> Agent 2
final_response = router(state) Describe alternatives you've considered
For maximum reliability and to avoid String/JSON hallucination entirely, the absolute smartest implementation of this RouterAgent class under the hood wouldn't use JSON string parsing at all. Instead, it would use Native LLM Tool Calling. The Router would convert the target sub_agents into callable functions, provide them to the classifier_agent, and cleanly map the resulting FunctionCall back to the ADK agent invocation.
Additional context
Since the Router pattern is one of the most fundamental multi-agent architectures (on par with Sequential/Parallel), supporting it natively out-of-the-box would massively improve the developer experience for medium-complexity ADK applications, eliminating the immediate need for users to jump into LangGraphAgent just for simple condition routing.
Would you like to implement this?
Yes! I have already begun developing this locally, ensuring that RouterAgent correctly inherits BaseAgent, utilizes BaseAgentState for resuming execution, and yields standard Event streams. If the core team is open to this addition, I would love to submit a Pull Request!
Activity
itsParv commentedon Mar 28, 2026
Implementation submitted in #5043.
klateefa commentedon Mar 30, 2026
@itsParv Thanks for the update. The request is currently being reviewed, and I will let you know if anything further is needed. Thank you for your understanding.
DeanChensj commentedon Jul 27, 2026
Thank you for the suggestion!
ADK currently supports conditional routing via Workflows, which is the preferred way for agent orchestration (composite agents like
SequentialAgentandParallelAgentare deprecated in favor of Workflows).You can achieve routing without JSON parsing boilerplate by combining
LlmAgent'soutput_schemawith a simple transition function in aWorkflow.Here is an example:
Additionally, if you want the classifier to route by directly calling the specialists as tools (without explicit workflow edges), you can use the sub-agents feature. When you add sub-agents to an
LlmAgent, they are automatically exposed as tools:Since the functionality is supported via these native patterns, we are closing this feature request. Feel free to reopen if you have further questions!