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,
cdinto theadk-trainingproject 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.
- Open your terminal, ensure you are in your
adk-trainingdirectory, and run the following command to scaffold a new agent:uv run adk create support_analyzer - Navigate into the newly created
support_analyzerdirectory. - Define a Pydantic Schema: In
agent.py, create a class namedSupportAnalysisthat 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.
- Update the Agent Configuration:
- Set the
output_schemato yourSupportAnalysisclass. - Set the
output_keyto"last_ticket_analysis".
- Set the
- Refine Instructions: Update the agent's
instructionto ensure it understands its job is to extract these three specific pieces of information from the user's input. - 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. - 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_schemainstead of just asking the LLM to "respond in JSON" in the text instructions? - Can the agent still call tools while
output_schemais set? What exactly doesoutput_schemaconstrain, 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