SDK for analyzing and evaluating agent traces stored in BigQuery.
Project description
BigQuery Agent Analytics SDK
An open-source Python SDK for analyzing, evaluating, and curating agent traces stored in BigQuery. Built on top of the BigQuery Agent Analytics, it provides a consumption-layer toolkit for agent observability, analysis, evaluation, and advanced capbilities like context graph at scale.
Overview
The BigQuery Agent Analytics SDK connects your AI agent telemetry in BigQuery to a rich set of evaluation, observability, and analytics capabilities. It is designed for ML engineers, data scientists, and platform teams who run agents in production and need to understand agent behavior, measure quality, and detect regressions — all through BigQuery SQL or Python.
Key Features
Observability
- Trace reconstruction and DAG visualization
- Per-event-type BigQuery views
- Observability dashboards (SQL and BigFrames)
Evaluation
- Code-based metrics (latency, turn count, error rate, token efficiency, cost)
- LLM-as-Judge scoring (correctness, hallucination, sentiment)
- Trajectory matching (exact, in-order, any-order)
- Multi-trial evaluation with pass@k / pass^k
- Grader composition (weighted, binary, majority strategies)
- Eval suite lifecycle management with graduation and saturation detection
- Static quality validation (ambiguous tasks, class imbalance, suspicious thresholds)
AI/ML Integration
- BigQuery AI.GENERATE, AI.EMBED, AI.CLASSIFY
- Anomaly detection and latency forecasting
- Categorical (Hatteras-style) evaluation via BigFrames
Advanced Analytics
- Context Graph — property graph linking traces to business entities with GQL traversal
- YAML-driven ontology extraction and materialization
- Long-horizon cross-session memory
- Multi-stage agent insights pipeline
- Drift detection for golden vs production question distributions
CLI (bq-agent-sdk)
- 12+ commands for diagnostics, evaluation, and CI/CD integration
Deployment Surfaces
- Remote Function (BigQuery SQL via Cloud Run)
- Python UDF scoring kernels
- Streaming evaluation (Cloud Scheduler + Cloud Run)
- Continuous query templates
Prerequisites
- Python 3.10+
- A Google Cloud project with BigQuery enabled
- Agent traces stored in BigQuery via the ADK BigQuery Trace Exporter
Installation
pip install bigquery-agent-analytics
With optional LLM judge support:
pip install bigquery-agent-analytics[llm]
With BigFrames support:
pip install bigquery-agent-analytics[bigframes]
Quick Start
from bigquery_agent_analytics import Client
client = Client(project_id="my-project", dataset_id="analytics")
trace = client.get_trace("trace-abc-123")
trace.render()
See SDK.md for the full API walkthrough with code examples for every feature.
Documentation
| Resource | Description |
|---|---|
| SDK Feature Reference | Complete API walkthrough with working code examples |
| Design Documents | Architecture decisions and design rationale |
| Examples | Notebooks, SQL scripts, and demos |
| Deployment Guides | Four deployment surfaces for Google Cloud |
Architecture
src/bigquery_agent_analytics/
│
├── Core
│ ├── client.py # High-level SDK client
│ ├── trace.py # Trace reconstruction & visualization
│ ├── views.py # Per-event-type BigQuery view management
│ ├── event_semantics.py # Canonical event type helpers & predicates
│ ├── serialization.py # Uniform serialization layer
│ └── formatter.py # Output formatting (json/text/table)
│
├── Evaluation
│ ├── evaluators.py # CodeEvaluator + LLMAsJudge
│ ├── trace_evaluator.py # Trajectory matching & replay
│ ├── multi_trial.py # Multi-trial runner + pass@k
│ ├── grader_pipeline.py # Grader composition pipeline
│ ├── eval_suite.py # Eval suite lifecycle management
│ └── eval_validator.py # Static validation checks
│
├── AI/ML
│ ├── ai_ml_integration.py # BigQuery AI/ML capabilities
│ ├── bigframes_evaluator.py # BigFrames DataFrame evaluator
│ ├── categorical_evaluator.py # Hatteras categorical evaluation
│ └── categorical_views.py # Categorical metric views
│
├── Analytics
│ ├── insights.py # Multi-stage insights pipeline
│ ├── feedback.py # Drift detection & question distribution
│ ├── context_graph.py # Property Graph: BizNode extraction, GQL
│ └── memory_service.py # Long-horizon agent memory
│
├── Ontology
│ ├── ontology_models.py # Pydantic models for ontology schema
│ ├── ontology_schema_compiler.py# YAML → compiled schema
│ ├── ontology_graph.py # Ontology graph construction
│ ├── ontology_materializer.py # Graph materialization to BigQuery
│ ├── ontology_property_graph.py # Property graph operations
│ └── ontology_orchestrator.py # End-to-end ontology pipeline
│
└── CLI & Deploy
├── cli.py # CLI entry point (bq-agent-sdk)
├── udf_kernels.py # Python UDF scoring kernels
└── udf_sql_templates.py # UDF SQL generation
Related Projects
- Google ADK — Agent Development Kit for building AI agents
- ADK BigQuery Trace Exporter — ADK plugin that writes agent traces to BigQuery
- BigQuery — Google Cloud analytics data warehouse
- BigQuery AI Functions — AI.GENERATE, AI.EMBED, AI.CLASSIFY, and more
Development
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
# Format code
pyink --config pyproject.toml src/ tests/
isort src/ tests/
Contributing
See CONTRIBUTING.md for guidelines.
License
Apache License 2.0 — see LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bigquery_agent_analytics-0.1.0.tar.gz.
File metadata
- Download URL: bigquery_agent_analytics-0.1.0.tar.gz
- Upload date:
- Size: 890.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6346424a0393bc5dc8fab7be83c4819bc502d8f4128858cd27888a4a56d906c9
|
|
| MD5 |
3f61baa7f20ccbfc1c24f45d3110e10d
|
|
| BLAKE2b-256 |
03d7bdb3c5f5bbfd743055dacfeb04b542bdbe421261ec90994aad3c46c68b1e
|
Provenance
The following attestation bundles were made for bigquery_agent_analytics-0.1.0.tar.gz:
Publisher:
release.yml on GoogleCloudPlatform/BigQuery-Agent-Analytics-SDK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bigquery_agent_analytics-0.1.0.tar.gz -
Subject digest:
6346424a0393bc5dc8fab7be83c4819bc502d8f4128858cd27888a4a56d906c9 - Sigstore transparency entry: 1287618092
- Sigstore integration time:
-
Permalink:
GoogleCloudPlatform/BigQuery-Agent-Analytics-SDK@c11b8a88d66ea4b94d26596bec86ea5771c18871 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/GoogleCloudPlatform
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c11b8a88d66ea4b94d26596bec86ea5771c18871 -
Trigger Event:
release
-
Statement type:
File details
Details for the file bigquery_agent_analytics-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bigquery_agent_analytics-0.1.0-py3-none-any.whl
- Upload date:
- Size: 170.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4abc5e892aed5d9d81114150939b962aecd3b530544071ffb4b327ee837b192a
|
|
| MD5 |
34b5025b39171e79b1f89c164f5a31e3
|
|
| BLAKE2b-256 |
6ac63242257b7ccf4fb3f6d0a0db7250aba3b015ee1e4e7649f910a32e82cc11
|
Provenance
The following attestation bundles were made for bigquery_agent_analytics-0.1.0-py3-none-any.whl:
Publisher:
release.yml on GoogleCloudPlatform/BigQuery-Agent-Analytics-SDK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bigquery_agent_analytics-0.1.0-py3-none-any.whl -
Subject digest:
4abc5e892aed5d9d81114150939b962aecd3b530544071ffb4b327ee837b192a - Sigstore transparency entry: 1287618136
- Sigstore integration time:
-
Permalink:
GoogleCloudPlatform/BigQuery-Agent-Analytics-SDK@c11b8a88d66ea4b94d26596bec86ea5771c18871 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/GoogleCloudPlatform
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c11b8a88d66ea4b94d26596bec86ea5771c18871 -
Trigger Event:
release
-
Statement type: