Skip to main content

Lab 4 Challenge: Customer Support Analyzer

Goalโ€‹

Your task is to build a "Support Analyzer" agent. Instead of returning plain text, the agent must analyze the user's support ticket and return a JSON object containing the categorization, sentiment, and a brief summary of the issue.

Lab Tasksโ€‹

Environment setup:

  • Local machine: If you're continuing the course in sequence, cd into the adk-training project you created in Module 2 and skip the block below -- your environment and dependencies already carry forward. If you're starting fresh at this module, create that project first:
    uv init adk-training --python 3.10 && cd adk-training
    uv add "google-adk>=2.1.0" python-dotenv
  • DevContainer / Codespaces (Alternative): If you opened this repository in a DevContainer or GitHub Codespaces, Python, uv, and the core ADK dependencies are already pre-installed in your container environment.
  1. Open your terminal, ensure you are in your adk-training directory, and run the following command to scaffold a new agent:
    uv run adk create support_analyzer
  2. Navigate into the newly created support_analyzer directory.
  3. Define a Pydantic Schema: In agent.py, create a class named SupportAnalysis that defines three fields:
    • category: A string (e.g., "billing", "technical", "general").
    • sentiment: A string (e.g., "positive", "negative", "neutral").
    • summary: A string containing a 1-sentence summary of the user's issue.
  4. Update the Agent Configuration:
    • Set the output_schema to your SupportAnalysis class.
    • Set the output_key to "last_ticket_analysis".
  5. Refine Instructions: Update the agent's instruction to ensure it understands its job is to extract these three specific pieces of information from the user's input.
  6. Run and Verify: Run the agent using uv run adk web support_analyzer (from the parent directory). In the Dev UI, test it with a phrase like "My screen is completely broken and I'm very angry about it!" and verify the response is a valid JSON object.
  7. Inspect State: After a few interactions, check the "Session State" in the Dev UI to confirm that "last_ticket_analysis" is being populated correctly.

Python Approach (Primary)โ€‹

Modify agent.py to include the Pydantic model and updated Agent parameters.

from pydantic import BaseModel
from google.adk import Agent

# TODO: Define your Pydantic schema
class SupportAnalysis(BaseModel):
# TODO: Add fields (category, sentiment, summary)
pass

root_agent = Agent(
name="support_analyzer_agent",
model="gemini-3.5-flash",
instruction="...", # TODO: Update instructions for categorization, sentiment, and summary
output_schema=..., # TODO: Link the schema
output_key=... # TODO: Set the output key
)

Self-Reflection Questionsโ€‹

  • Why is it better to use output_schema instead of just asking the LLM to "respond in JSON" in the text instructions?
  • Can the agent still call tools while output_schema is set? What exactly does output_schema constrain, and what does it leave free?
  • Look at the Dev UI's "Session State". How could another agent in a future multi-agent system use the data stored in the "last_ticket_analysis" key?

๐Ÿ” Reference Solution Vaultโ€‹

๐Ÿ”

Module 04 Reference Solution Vault

Active Comprehension Gate โ€ข Zero Guessable URLs โ€ข Guided Verification

Step 1/3: Question 1 of 3

In ADK 2.0 object patterns, how do you directly access the LLM response text from an `LlmResponse` object?