Skip to main content

From RAG to Autonomous Data Analysis: My Google Cloud Gen AI Academy Journey

Building grounded AI, BigQuery data agents, secure sandbox execution, and human-in-the-loop workflows with Gemini, Google ADK, and Cloud Run

Updated 13 min readMarkdown
From RAG to Autonomous Data Analysis: My Google Cloud Gen AI Academy Journey

From RAG to Autonomous Data Analysis: My Google Cloud Gen AI Academy Journey

Building, deploying, and securing AI agents with Google ADK, Gemini, Cloud Run, BigQuery, Google Sheets, and Cloud Run Sandboxes

What happens when an AI agent moves beyond answering questions and starts retrieving data, analyzing it, executing code, and taking actionβ€”with human approval?

That was the question I explored while completing the three-track hands-on codelabs of the Google Cloud Gen AI Academy APAC Edition.

Over the three tracks, I progressively built three different capabilities:

Track 1 β†’ RAG-powered AI application
Track 2 β†’ Natural-language BigQuery data agent
Track 3 β†’ Secure business-analysis agent with sandbox execution and human-in-the-loop actions

Rather than treating the codelabs as three isolated exercises, I looked at them as a progression toward something much more interesting:

An AI agent that can understand β†’ retrieve β†’ analyze β†’ execute β†’ recommend β†’ act, while keeping humans in control.


🧭 The Journey

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 GOOGLE CLOUD GEN AI JOURNEY                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

        TRACK 1
           β”‚
           β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚       RAG       β”‚
   β”‚                 β”‚
   β”‚ Retrieve data   β”‚
   β”‚ Ground answers  β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚
            β–Ό
        TRACK 2
           β”‚
           β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚   DATA AGENT    β”‚
   β”‚                 β”‚
   β”‚ Natural Languageβ”‚
   β”‚      ↓          β”‚
   β”‚    BigQuery     β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚
            β–Ό
        TRACK 3
           β”‚
           β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚   BUSINESS AGENT       β”‚
   β”‚                        β”‚
   β”‚ Analyze β†’ Execute      β”‚
   β”‚ Recommend β†’ Approve    β”‚
   β”‚            ↓           β”‚
   β”‚          Action        β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Each track introduced another layer of capability.


β˜• Track 1 β€” Building a RAG AI Agent with Google ADK and Cloud Run

The first track focused on understanding the fundamentals of Retrieval-Augmented Generation (RAG).

The scenario was simple:

Build an AI barista that can recommend items from a coffee-shop menu without hallucinating products that don't exist.

But behind this simple example were several important AI engineering concepts.

What I built

The application used:

  • Google ADK

  • Gemini

  • Python

  • Streamlit

  • Cloud Run

  • A structured menu.json dataset

The architecture looked roughly like this:

                 USER
                  β”‚
                  β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚ Streamlit Chat UIβ”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
                 β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚    ADK Agent     β”‚
        β”‚   Gemini Model   β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
                 β”‚ Tool Call
                 β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚    get_menu()    β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
                 β–Ό
             menu.json
                 β”‚
                 β–Ό
        Grounded Response

Instead of putting the entire menu directly into the agent's instructions, the agent could call a tool:

def get_menu() -> str:
    with open("menu.json", "r") as f:
        menu_data = json.load(f)

    return json.dumps(menu_data)

The important idea here was grounding.

If the menu doesn't contain a matcha frappuccino, the agent shouldn't invent one.

For example:

User: Do you have a matcha frappuccino?

The expected behavior is essentially:

Sorry, that item isn't available on our menu.

That is much better than allowing a generative model to confidently create an imaginary product.


🧠 Why Tool-Based Retrieval Matters

One of my biggest takeaways from Track 1 was that retrieval isn't only about accuracy.

It is also about context efficiency.

Imagine a coffee shop with:

  • 8 products

  • 500 products

  • 50,000 products

Putting the entire dataset inside the system prompt becomes increasingly inefficient.

Instead:

User Question
      β”‚
      β–Ό
Does the agent need menu data?
      β”‚
     YES
      β”‚
      β–Ό
Call retrieval tool
      β”‚
      β–Ό
Retrieve relevant data
      β”‚
      β–Ό
Generate grounded answer

This pattern becomes much more interesting when the data source evolves from a local JSON file to a managed database or vector search system.


πŸš€ Deploying the Agent

The application was deployed to Cloud Run.

One useful lesson here was that source-based deployment can dramatically simplify the deployment process.

Instead of manually building and managing a container image, Cloud Run can use buildpacks to package the application.

Conceptually:

Python Source
     β”‚
     β–Ό
requirements.txt
     β”‚
     β–Ό
Cloud Build / Buildpacks
     β”‚
     β–Ό
Container
     β”‚
     β–Ό
Cloud Run
     β”‚
     β–Ό
Public AI Application

This made the transition from local prototype β†’ cloud application surprisingly straightforward.


πŸ“Š Track 2 β€” Turning Natural Language into Data Analysis

The second track changed the problem completely.

Instead of asking an agent:

"What's on the coffee menu?"

the idea became:

"Ask questions about a real dataset using natural language."

For this track, I worked with the public New York Citi Bike dataset in BigQuery.

The dataset contained historical trip information and station information.

The trip table included information such as:

  • Trip duration

  • Start and stop times

  • Start and end stations

  • Bike IDs

  • Rider type

  • Gender

  • Birth year

  • Customer plan

The station information included:

  • Station location

  • Capacity

  • Available bikes

  • Available docks

  • Disabled bikes

  • Operational status

That creates a much more interesting environment for an AI data agent.


πŸ”Ž From Question β†’ Data β†’ Answer

The core idea can be visualized like this:

             USER
              β”‚
              β”‚
       "Which stations
        are busiest?"
              β”‚
              β–Ό
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚   AI AGENT    β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
        Understand intent
               β”‚
               β–Ό
       Generate / execute
          data query
               β”‚
               β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚    BigQuery   β”‚
        β”‚               β”‚
        β”‚ Citi Bike     β”‚
        β”‚ Dataset       β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                β”‚
                β–Ό
          Query results
                β”‚
                β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚ Gemini Agent  β”‚
        β”‚ interprets    β”‚
        β”‚ results       β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                β”‚
                β–Ό
          Human-friendly
             answer

This is where the concept of an AI data analyst starts to become realistic.

Instead of requiring a user to know SQL, the user can communicate in natural language.


🧩 Why This Is Different From Basic Chat

A normal chatbot might answer:

"Citi Bike is a bike-sharing system in New York."

A data agent can potentially answer questions such as:

"Which stations had the highest usage?"

"What was the average trip duration?"

"Compare subscriber and customer behavior."

"Which time periods experienced the highest demand?"

The important transition is:

LLM as a text generator

↓

LLM as an interface to data

That distinction is extremely important for enterprise AI.


☁️ Cloud Run + ADK

The agent was then deployed using Google Cloud infrastructure.

The architecture became:

                 USER
                  β”‚
                  β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚    ADK       β”‚
          β”‚    Agent     β”‚
          β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
                 β–Ό
          Google Cloud
          / Vertex AI
                 β”‚
                 β–Ό
             BigQuery
                 β”‚
                 β–Ό
            Data Results
                 β”‚
                 β–Ό
          Natural Language
             Response

This track made me think less about "How do I make a chatbot?"

and more about:

"How do I make an AI interface for an organization's data?"


πŸ” Track 3 β€” From Data Analysis to an Agent That Can Act

This was the track I found the most interesting.

The scenario:

A coffee shop is preparing for a huge university graduation weekend.

The agent receives historical Point-of-Sale data and a graduation ceremony schedule.

Its job is to discover operational bottlenecks.

But there is an important constraint:

The agent should not immediately change business data.

It should first analyze the situation, explain its findings, make recommendations, and ask for permission.

Only after explicit approval should it modify the spreadsheet.

This introduced something beyond RAG and data analysis:

Human-in-the-Loop AI


🧠 The Track 3 Architecture

                         MANAGER
                            β”‚
                            β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   Chat UI    β”‚
                    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   ADK Agent  β”‚
                    β”‚              β”‚
                    β”‚ Gemini Model β”‚
                    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚             β”‚              β”‚
             β–Ό             β–Ό              β–Ό
        Google Sheets   Sandbox       Analysis
             β”‚             β”‚              β”‚
             β”‚             β–Ό              β”‚
             β”‚       Python / Shell       β”‚
             β”‚       execution             β”‚
             β”‚             β”‚              β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β–Ό
                    Insights & Findings
                           β”‚
                           β–Ό
                    Recommendations
                           β”‚
                           β–Ό
                    HUMAN APPROVAL
                           β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
                    β”‚             β”‚
                   NO            YES
                    β”‚             β”‚
                    β–Ό             β–Ό
                  Stop       Update Sheet

This architecture introduced a very important principle:

An agent should not necessarily be given unrestricted authority just because it can technically perform an action.


πŸ§ͺ Why a Sandbox?

One of the most interesting components was the Cloud Run sandbox.

The agent can dynamically write and execute code to analyze information.

For example, rather than asking the LLM to mentally calculate everything, it can create a Python script to process the data.

Conceptually:

Business Question
       β”‚
       β–Ό
    AI Agent
       β”‚
       β–Ό
 Generate Python analysis
       β”‚
       β–Ό
 Cloud Run Sandbox
       β”‚
       β–Ό
 Execute code safely
       β”‚
       β–Ό
 Analysis results
       β”‚
       β–Ό
 AI interprets results

This is powerful because AI agents aren't limited to generating text.

They can become systems that:

reason β†’ create code β†’ execute β†’ inspect results β†’ reason again


πŸ“ˆ Finding Operational Bottlenecks

The sample POS data contained variables such as:

  • Drip Coffee

  • Cold Brew

  • Extra Espresso

  • Alternative Milk

  • Pastries

  • Cashiers Working

  • Wait Time

The agent was instructed to look for relationships between:

Demand + beverage complexity + staffing + wait time

For example:

High Cold Brew
      +
High Extra Espresso
      +
High Alternative Milk
      +
Only 2 Cashiers
      +
Wait Time > 10 minutes
      β”‚
      β–Ό
Potential fulfillment bottleneck
      β”‚
      β–Ό
Recommend Support Barista

This is more useful than simply reporting:

"Wait time was 12 minutes."

The agent tries to answer:

"Why did the wait time increase, and what should the manager do about it?"

That's the difference between descriptive analytics and decision-support AI.


βœ‹ Human Approval Before Action

This was probably the most important design pattern in Track 3.

The agent doesn't immediately write recommendations into the spreadsheet.

Instead:

ANALYZE
   ↓
DISCOVER
   ↓
RECOMMEND
   ↓
ASK FOR APPROVAL
   ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Human decides β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
   β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
   β”‚         β”‚
  YES        NO
   β”‚         β”‚
   β–Ό         β–Ό
WRITE      STOP

Only after explicit approval can the agent:

  1. Check whether the TODO-2026 tab exists.

  2. Create it if necessary.

  3. Add the approved tasks.

  4. Confirm exactly what was written.

This is a practical example of human-in-the-loop agent design.


πŸ” Security Lessons I Took Away

The three tracks also changed how I think about AI security.

It is easy to focus on:

"Can the model answer correctly?"

But production AI requires another question:

"What is the model allowed to do?"

Track 3 demonstrated the Principle of Least Privilege by using a dedicated service account rather than giving the application unnecessarily broad permissions.

The conceptual model is:

          AI AGENT
              β”‚
              β–Ό
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚ Permissions β”‚
       β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
              β”‚
      Only required
        capabilities
              β”‚
       β”Œβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”
       β–Ό      β–Ό      β–Ό
    Gemini  Sheets  Sandbox

This is a lesson I want to carry into future agent projects.


πŸ›‘οΈ Another Lesson: AI Needs Guardrails

Across the three tracks, I saw three different types of guardrails.

Track 1 β€” Data Guardrail

Only recommend products retrieved from the menu.

Track 2 β€” Data Access

Use the data source to answer analytical questions rather than inventing statistics.

Track 3 β€” Action Guardrail

Don't modify business data until a human explicitly approves the recommendation.

Together:

        AI AGENT
           β”‚
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
   β–Ό       β–Ό        β–Ό
GROUND   ACCESS   ACTION
  DATA   CONTROL  CONTROL
   β”‚       β”‚        β”‚
   β–Ό       β–Ό        β–Ό
 RAG    BigQuery   Human
                  Approval

πŸ—οΈ The Technology Stack

The overall journey exposed me to a broad Google Cloud Gen AI stack:

Layer Technology
AI Models Gemini
Agent Framework Google ADK
Application Python
UI Streamlit / Web UI
Data JSON / BigQuery / Google Sheets
Cloud Compute Cloud Run
Code Execution Cloud Run Sandbox
Analytics BigQuery
Authentication Google Cloud IAM
Deployment Cloud Build / Cloud Run
API Integration Google Cloud APIs

πŸ”„ The Bigger Picture

Looking back at all three tracks, I see them as three stages of an agent's evolution.

Stage 1 β€” Grounded Generation

Question
   ↓
Retrieve
   ↓
Generate

Stage 2 β€” Data Intelligence

Question
   ↓
Understand
   ↓
Query Data
   ↓
Analyze
   ↓
Explain

Stage 3 β€” Agentic Decision Support

Question
   ↓
Retrieve Data
   ↓
Analyze
   ↓
Execute Code
   ↓
Discover Insight
   ↓
Recommend Action
   ↓
Human Approval
   ↓
Take Action

That progression is what made completing the three tracks valuable to me.


πŸ’‘ What I Learned

The biggest lessons weren't simply about APIs or commands.

They were architectural.

1. RAG is about grounding

An AI system becomes much more useful when its responses are connected to trusted data.

2. Agents can become interfaces to data

Natural language can become an interface for users who don't know SQL or complex data systems.

3. Code execution expands agent capabilities

An agent can use code as a reasoning and analysis tool instead of relying entirely on language-model reasoning.

4. Permissions matter

An agent should receive only the permissions it actually needs.

5. Human approval is powerful

For business-critical actions, the best agent isn't necessarily the one that acts autonomously.

Sometimes the best design is:

AI recommends. Human decides. AI executes.

πŸš€ What's Next?

These codelabs gave me a strong foundation, but they also raised bigger questions.

What happens if the local JSON data becomes a production database?

What happens when the agent needs persistent memory?

What happens when multiple agents collaborate?

What happens when the agent needs to monitor data continuously instead of waiting for a user prompt?

And most importantly:

How do we build agents that are not only intelligent, but reliable, secure, observable, and genuinely useful?

Those are the areas I want to explore next.

🎯 Final Takeaway

I started these codelabs thinking about Gemini and AI agents.

I finished them thinking much more about AI system architecture.

From a coffee menu:

RAG β†’ Grounded answers

To Citi Bike:

Natural language β†’ Data analysis

To a coffee-shop manager:

Data β†’ Code execution β†’ Insights β†’ Recommendations β†’ Human-approved action

The interesting part of agentic AI isn't simply making an AI that can talk.

It's building systems where AI can understand context, access the right data, use tools, reason over results, and safely participate in real workflows.

And that's the direction I'm excited to keep building toward. πŸš€

🧰 Technologies explored

Google ADK β€’ Gemini β€’ Cloud Run β€’ BigQuery β€’ Google Sheets β€’ Cloud Run Sandboxes β€’ Python β€’ Streamlit β€’ IAM β€’ Cloud Build

πŸ‘¨β€πŸ’» About Me

I'm Mappillai Meeran, an MCA student and developer exploring AI agents, cloud technologies, full-stack development, and practical AI applications.

I'm particularly interested in moving beyond AI demos and building systems that solve real problems.

This is only the beginning. πŸš€

Tags

#GoogleCloud #GenerativeAI #Gemini #GoogleADK #AIAgents #CloudRun #BigQuery #VertexAI #Python #RAG #AgenticAI #MachineLearning #CloudComputing #AIEngineering #GenAI

About the author

  • πŸ‘‹ Hi, I’m Mappillai Meeran, an MCA student and developer passionate about AI Agents, Google Cloud, and full-stack development. I enjoy turning ideas into working products and learning by building. My interests include Generative AI, agentic systems, cloud computing, web development, and developer tools. I’ve worked with technologies such as Python, Java, JavaScript, React, Node.js, SQL, MongoDB, Google Cloud, Gemini, Google ADK, and Cloud Run. πŸš€ I use this blog to document what I build, what I learn, technical experiments, project journeys, and lessons from hackathons and cloud/AI programs. Build β†’ Break β†’ Learn β†’ Improve β†’ Share. Always exploring what’s possible with technology.

No comments yet. Be the first to comment.