✦ Want a lab built just for you? ✦
Request a Lab ↗

Building a Stateful Cloud Cost Advisor with Google ADK

About this lab

You are a cloud infrastructure engineer at NimbusScale, a fast-growing SaaS startup whose monthly GCP bill just crossed $30,000. The CFO wants a 20% cost reduction within the quarter, but your team manages 15 different cloud services and nobody has time to audit each one manually. You need a smarter way to analyze spending patterns, surface optimization opportunities, and track which services have been reviewed.

In this lab, you will build a stateful cloud cost advisor agent using the Google Agent Development Kit (ADK). You will create tool functions that query service costs, pull 6-month spending trends, and generate optimization recommendations. Using ToolContext, you will implement session state so the agent remembers which services have been reviewed across conversation turns. You will also configure output_key to automatically store agent responses in session state, giving you hands-on experience with ADK's core state management patterns.

Lab details

  • Level: Beginner
  • Cloud: GCP
  • Domain: AI Engineering
  • Duration: 75 minutes

What you will learn

  • Set up a Google ADK project with the correct package structure for adk web
  • Build tool functions that query JSON datasets and return structured results
  • Use ToolContext to read and write session state inside tool functions
  • Track user interactions across conversation turns using persistent state
  • Configure output_key to automatically store agent responses in state
  • Test tools independently and run the agent with the ADK web interface

Concepts covered

  • Google ADK
  • ToolContext
  • Session State
  • output_key
  • Agent Tools
  • Gemini 2.5 Flash

Technologies used

  • Google ADK
  • Gemini 2.5 Flash
  • Python
  • ToolContext

Prerequisites

  • Basic Python knowledge (functions, dictionaries, lists)
  • A Google AI API key (free tier available at aistudio.google.com)

Topics

  • Google ADK
  • ToolContext
  • Session State
  • AI Agent
  • Cost Optimization
  • Gemini
  • Python
  • GCP