Google ADK - taking a look at LLMAgent, Agent, AgentTool, SubAgent, SequentialAgent and ParrallelAgent

This covers some confusion around agent in Google ADK. So what is the differences between LLMAgent, Agent, SequentialAgent and ParallelAgent? 


LLMAgent is used for reasoning, understanding your intention, making decision and ability to interact with tools. 

To use LlmAgent here is an example

capital_agent = LlmAgent( model="gemini-2.5-flash", name="capital_agent", description="Answers user questions about the capital city of a given country." # instruction and tools will be added next )

Agent is an alis for LLMAgent. 

SequentialAgent on the other hand are pre-defined sequential workflow to be carried out by an orchestration agent. In this case, it would be Agent / LLMAgent. 

Code example of sequentialAgent can be shown here 


location_strategy_pipeline = SequentialAgent(
    name="LocationStrategyPipeline",
    description="""Comprehensive retail location strategy analysis pipeline.

""",
    sub_agents=[
        market_research_agent,  # Part 1: Market research with search
        competitor_mapping_agent,  # Part 2A: Competitor mapping with Maps
        gap_analysis_agent,  # Part 2B: Gap analysis with code exec
        strategy_advisor_agent,  # Part 3: Strategy synthesis
        report_generator_agent,  # Part 4: HTML report generation
        infographic_generator_agent,  # Part 5: Infographic generation
    ],
)


ParallelAgent execute this workflow in parrallel. 

When initializing Agent you might have seen  Sub Agent and AgentTool. So what is the differences? For example take a look at this code here 


root_agent = Agent(
    model=FAST_MODEL,
    name=APP_NAME,
    description="A strategic partner for retail businesses, guiding them to optimal physical locations that foster growth and profitability.",
    instruction="""Your primary role is to orchestrate the retail location analysis.
1. Start by greeting the user.
2. Check if the `TARGET_LOCATION` (Geographic area to analyze (e.g., "Indiranagar, Bangalore")) and `BUSINESS_TYPE` (Type of business (e.g., "coffee shop", "bakery", "gym")) have been provided.
3. If they are missing, **ask the user clarifying questions to get the required information.**
4. Once you have the necessary details, call the `IntakeAgent` tool to process them.
5. After the `IntakeAgent` is successful, delegate the full analysis to the `LocationStrategyPipeline`.
Your main function is to manage this workflow conversationally.""",
    sub_agents=[location_strategy_pipeline],
    tools=[AgentTool(intake_agent)],  # Part 0: Parse user request
)

We can see sub_agents and tools which accepts type AgentTool. 

sub_agents are pretty straight forward - this agent will be calling sub agent (this can be SequentialAgent or ParallelAgent or simply another agent). When sub agents are use, this means it is a FULL delegation and the caller is out of the loop.  

tools are basically what utility or arsenal available to the agent to use? It can be google_search or invoking weather data. 

What is the purpose of AgentTool? Agent tool allows us to delegate task to an agent and it will go do some work then pass back results to the calling agent A

 In this example, lets say we have Agent A which calls Agent B (AgentTool). Agent B will do some work, get and process user input and then pass it back to Agent A. Agent A look at the input and if it is some information is missing, it will go and ask Agent B to work harder. 

Take a look at the code here:

root_agent = Agent(
    model=FAST_MODEL,
    name=APP_NAME,
    description="A strategic partner for retail businesses, guiding them to optimal physical locations that foster growth and profitability.",
    instruction="""Your primary role is to orchestrate the retail location analysis.
1. Start by greeting the user.
2. Check if the `TARGET_LOCATION` (Geographic area to analyze (e.g., "Indiranagar, Bangalore")) and `BUSINESS_TYPE` (Type of business (e.g., "coffee shop", "bakery", "gym")) have been provided.
3. If they are missing, **ask the user clarifying questions to get the required information.**
4. Once you have the necessary details, call the `IntakeAgent` tool to process them.
5. After the `IntakeAgent` is successful, delegate the full analysis to the `LocationStrategyPipeline`.
Your main function is to manage this workflow conversationally.""",
    sub_agents=[location_strategy_pipeline],
    tools=[AgentTool(intake_agent)],  # Part 0: Parse user request
)

---------------------------------------------------------------

intake_agent = LlmAgent(
    name="IntakeAgent",
    model=FAST_MODEL,
    description="Parses user request to extract target location and business type",
    instruction=INTAKE_INSTRUCTION,
    generate_content_config=types.GenerateContentConfig(
        http_options=types.HttpOptions(
            retry_options=types.HttpRetryOptions(
                initial_delay=RETRY_INITIAL_DELAY,
                attempts=RETRY_ATTEMPTS,
            ),
        ),
    ),
    output_schema=UserRequest,
    output_key="parsed_request",
    after_agent_callback=after_intake,
)

More info available here

https://adk.dev/tools-custom/function-tools/#customization











Comments

Popular posts from this blog

vllm : Failed to infer device type

android studio kotlin source is null error

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20