This repository demonstrates how to use Google BigQuery as a unified platform for AI Agent Observability ("Agent Ops"), Governance, Analytics, Evaluation, and Memory.
It features a comprehensive Jupyter notebook that simulates an e-commerce customer support agent, "ShopBot", and showcases how to capture, analyze, and optimize its behavior using the Google Agent Development Kit (ADK) and BigQuery's built-in AI capabilities.
The primary goal of this demo is to show how developers can move beyond simple logging and build a production-grade observability stack for AI agents without leaving the data warehouse. Key capabilities demonstrated include:
- Real-time Observability: Streaming agent traces, decisions, and tool inputs/outputs directly to BigQuery.
- Root Cause Analysis (RCA): Using Gemini 2.5 Flash within BigQuery to automatically diagnose why an agent session failed.
- Cost Tracking: Granular token and cost estimation per session and per user.
- Semantic Search: Retrieving past similar sessions to solve current user problems using BigQuery Vector Search.
- Structured Memory: Automatically extracting structured facts (user intent, outcomes) from unstructured conversation logs to build long-term agent memory.
Demo_Plan_BigQuery_for_Agent_Ops_Unified_Platform_Public.ipynb: The main demo notebook. It contains the complete end-to-end workflow, from raw telemetry ingestion to AI-powered analysis and visualization.
- A Google Cloud Project with billing enabled.
- The following APIs enabled:
- BigQuery API
- BigQuery Connection API
- Vertex AI API
- A BigQuery Cloud Resource Connection (for calling Gemini models from SQL).
You can run this notebook in any Jupyter environment. We have provided "Open in..." links for convenience:
| Environment | Link |
|---|---|
| Google Colab | Link |
| Vertex AI Workbench | Link |
| BigQuery Studio | Link |
Steps:
- Open the notebook in your preferred environment.
- Update the
PROJECT_ID,DATASET_ID, andCONNECTION_IDvariables in the Configuration cell to match your Google Cloud environment. - Run the cells sequentially.
The notebook guides you through five distinct phases of Agent Ops:
- Real-time Feed: View raw traces of agent
LLM_RESPONSE,TOOL_USE, andUSER_MESSAGEevents. - Behavior Analysis: SQL-based analytics to visualize Tool Usage distribution and Error Rates.
- Deep Dive & RCA: Using
AI.GENERATEto read conversation logs and explain why a specific session failed (e.g., distinguishing between a tool error and an LLM hallucination). - Enhancing Agent Intelligence:
- Vector Search: Finding relevant past sessions to provide context for new queries.
- Structured Memory: Creating a JSON object of "facts" from a conversation to store in a user profile.
- Visualization: Native Python visualizations (using Altair) right inside BigQuery Studio to track cost and performance KPIs.
- Google BigQuery: Data warehouse and engine for SQL analysis.
- BigQuery ML (BQML): For calling remote models (Gemini, Text Embedding) directly from SQL.
- Google Agent Development Kit (ADK): (Conceptual) Used for the agent instrumentation plugin.
- Python (Pandas, Altair): For data manipulation and visualization.
This is a demonstration project and is not an officially supported Google product. The "ShopBot" agent data is simulated for demonstration purposes.