Skip to main content

Llm Agent

The LlmAgent is the fundamental unit of intelligence in the Google Agent Development Kit (ADK). It wraps a Large Language Model (Gemini) with Instructions, Configuration, and State Management.

When you need an AI to perform a task—whether it's writing code, summarizing text, or analyzing data—you use an LlmAgent.


Visual Guide: Creating an Agent

1. Drag & Drop

  1. Locate the Sidebar on the left side of the builder.
  2. Expand the Agents section.
  3. Click and drag the LlmAgent card onto the infinite canvas.
  4. A purple node will appear representing your new agent.

2. Selection & Properties

Click on the node to open the Properties Panel on the right side of the screen. This panel is divided into three logical sections:

  1. General: Identity and Core Instructions.
  2. Generation Config: Fine-tuning the AI's creativity and output format.
  3. Routing & State: Managing memory and context flow.

1. General Settings

These are the required fields that define who the agent is.

PropertyDescriptionBest Practice
Agent NameA unique identifier for this agent.Use snake_case (e.g., research_assistant). This name becomes a variable in the code, so avoid spaces.
ModelThe specific Gemini model version to power this agent.gemini-2.0-flash: Best for speed and general tasks.
gemini-3-pro-preview: Best for complex reasoning and coding.
gemini-2.5-flash-image: Specialized for vision tasks.
System InstructionThe "Prompt" that defines the agent's persona and rules.Be specific. Define the role ("You are a coder"), the input format ("You will receive a CSV"), and the output format ("Reply only with Python code").

2. Generation Configuration

Click the Generation Config dropdown in the properties panel to access advanced controls. These settings determine how the model "thinks" and generates text.

Creativity Controls

  • Temperature (0.0 - 2.0):

    • Low (0.0 - 0.5): Deterministic and focused. Use this for code generation, data extraction, or factual Q&A.
    • High (1.0 - 2.0): Creative and diverse. Use this for brainstorming, poetry, or creative writing.
    • Default: 1.0
  • Top P (0.0 - 1.0):

    • Also known as "Nucleus Sampling". It limits the pool of potential next words to the top cumulative probability.
    • Lower values make the text more coherent and predictable.
  • Top K (1 - 100):

    • Limits the model to picking from the top K most likely next words.
    • Default: 40.

Output Controls

  • Max Output Tokens:

    • Sets a hard limit on the response length.
    • Default: 8192. Increase this if you expect the agent to write long essays or large code files.
  • Response MIME Type:

    • text/plain: Standard free-form text response.
    • application/json: Forces the model to output a valid JSON object. This is critical when chaining agents where the next agent expects structured data.

Structured Output (JSON Schema)

When you select application/json as the MIME Type, a "Configure Output Schema" button appears.

Clicking this opens the Schema Editor, allowing you to define the exact keys and data types the AI must return.

Example Schema for a Recipe Generator:

  • Key: recipe_name | Type: STRING | Desc: The title of the dish.
  • Key: prep_time | Type: INTEGER | Desc: Time in minutes.
  • Key: ingredients | Type: STRING | Desc: A markdown list of items.
Why use Schemas?

Defining a schema ensures reliability. Instead of parsing text with Regex, your code can reliably access response.recipe_name.


3. Routing & State

This section controls how the agent interacts with the conversation history and how it passes data to other agents.

Context Management

  • Include History (Toggle):
    • ON (Default): The agent sees the entire conversation history leading up to this point. It knows what previous agents said.
    • OFF: The agent starts with a "Fresh Context". It only sees its own System Instruction and the immediate input. This saves tokens and reduces confusion for specialized tasks.

State Isolation

  • Block Parent Transfer:

    • If checked, variables created by this agent are not passed back up to the parent orchestrator. Useful for keeping the global state clean.
  • Block Peer Transfer:

    • If checked, variables created by this agent are not visible to sibling agents in the same chain.

Auto-Generated Fields

  • Output Key:
    • This field is read-only and auto-generated based on your Agent Name.
    • Example: If Agent Name is writer_bot, Output Key is output_writer_bot.
    • This is the variable name used to store the agent's response in the session memory. Subsequent agents can reference this data.

Example Workflow

Goal: Create a travel planner.

  1. Agent 1: researcher
    • Instruction: "Find 3 hotels in Paris."
    • Output Key: output_researcher
  2. Agent 2: writer
    • Instruction: "Take the hotels listed in {output_researcher} and write a polite email to the user recommending them."
    • Include History: ON (so it can read the output).

By chaining LlmAgents visually, you can build complex, reliable applications without writing boilerplate code.