Skip to content

feat(agents): add native RouterAgent for LLM-based conditional routing#5043

Open
itsParv wants to merge 1 commit intogoogle:mainfrom
itsParv:feature/router-agent
Open

feat(agents): add native RouterAgent for LLM-based conditional routing#5043
itsParv wants to merge 1 commit intogoogle:mainfrom
itsParv:feature/router-agent

Conversation

@itsParv
Copy link
Copy Markdown

@itsParv itsParv commented Mar 28, 2026

Summary

Closes #5032
Adds a native RouterAgent to the google.adk.agents package - a specialized agent that uses an LLM to classify user intent and conditionally delegate to one of several sub-agents.

Design

Two-phase execution model:

  1. Classification phase - The router's own LLM analyzes the user message against route descriptions and selects the best-matching sub-agent.
    1. Delegation phase - The selected sub-agent is invoked to handle the request.

Key components

File Purpose
router_agent.py Core RouterAgent class with classification + delegation logic
router_agent_config.py Pydantic config model (RouterAgentConfig, RouteConfig)
init.py Public exports

Quality

  • Pylint: 10/10 (zero warnings)
    • Formatter: pyink (Google style)
    • Follows existing ADK patterns (LlmAgent, BaseAgent, InvocationContext)

Testing

  • Manual end-to-end validation with Gemini model
    • Classification accuracy verified across multiple intent categories

@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 28, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Mar 28, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Mar 28, 2026

Response from ADK Triaging Agent

Hello @itsParv, thank you for your contribution!

Before we can merge this PR, you'll need to sign the Contributor License Agreement (CLA). It seems like the CLA check has failed. You can find more information about the CLA and sign it at https://cla.developers.google.com/.

Thanks!

Introduces RouterAgent, a new workflow agent that uses a classifier
sub-agent to determine which specialist sub-agent should handle a
given request. This eliminates manual if-else routing boilerplate.

Key features:
- Two-phase execution: classification then delegation
- JSON-based route parsing with Markdown code-fence cleanup
- Configurable routing_key and route mappings
- default_route fallback for unmatched or malformed classifier output
- Full resumability support via RouterAgentState
- YAML config support via RouterAgentConfig

Closes google#1947
@itsParv itsParv force-pushed the feature/router-agent branch from 9192f17 to 06bf446 Compare March 28, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Native RouterAgent (Tool-Calling Orchestrator) to replace JSON-parsing boilerplate

2 participants