-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Description
The BigQuery Agent Analytics plugin works correctly when running locally with [adk web], but fails to insert events into BigQuery when the agent is deployed to Vertex AI Agent Engine using [AdkApp]. No errors are raised - the plugin silently fails to log any events.
Environment
ADK Version: 1.21.0+
Python Version: 3.12
Deployment Target: Vertex AI Agent Engine (Reasoning Engine)
BigQuery Dataset Location: us-central1
Steps to Reproduce
1. Agent Configuration ([agent.py]
import os
from dotenv import load_dotenv
load_dotenv()
from google.adk.apps import App
from google.adk.plugins.bigquery_agent_analytics_plugin import (
BigQueryAgentAnalyticsPlugin,
BigQueryLoggerConfig
)
from google.adk.agents import Agent
from google.adk.models.google_llm import Gemini
PROJECT_ID = os.environ.get("GOOGLE_CLOUD_PROJECT", "my-project")
DATASET_ID = os.environ.get("BIG_QUERY_DATASET_ID", "agent_engine_metrics")
LOCATION = os.environ.get("GOOGLE_CLOUD_LOCATION", "us-central1")
os.environ['GOOGLE_CLOUD_PROJECT'] = PROJECT_ID
os.environ['GOOGLE_CLOUD_LOCATION'] = LOCATION
os.environ['GOOGLE_GENAI_USE_VERTEXAI'] = 'True'
bq_config = BigQueryLoggerConfig(
enabled=True,
batch_size=1,
shutdown_timeout=10.0
)
bq_logging_plugin = BigQueryAgentAnalyticsPlugin(
project_id=PROJECT_ID,
dataset_id=DATASET_ID,
table_id="agent_events_v2",
config=bq_config,
location=LOCATION
)
llm = Gemini(model="gemini-2.5-flash")
root_agent = Agent(
model=llm,
name='multi_tool_agent',
instruction="You are a helpful assistant."
)
app = App(
name="multi_tool_agent",
root_agent=root_agent,
plugins=[bq_logging_plugin],
)
2. Deployment Script ([deploy.py]
import vertexai
from vertexai import agent_engines
from vertexai.preview.reasoning_engines import AdkApp
from multi_tool_agent.agent import root_agent, bq_logging_plugin
vertexai.init(
project="my-project",
location="us-central1",
staging_bucket="gs://my-bucket",
)
adk_app = AdkApp(
agent=root_agent,
plugins=[bq_logging_plugin],
enable_tracing=True
)
remote_agent = agent_engines.create(
adk_app,
display_name="multi_tool_agent",
requirements=[
"google-adk[bigquery-analytics]>=1.21.0",
"google-cloud-aiplatform[agent_engines]>=1.91.0",
"google-genai>=1.5.0,<2.0.0",
"google-cloud-bigquery>=3.0.0",
"google-cloud-bigquery-storage>=2.0.0",
],
extra_packages=["multi_tool_agent"],
)
Expected Behavior
After deployment to Agent Engine, when the agent processes requests, events (LLM_REQUEST, LLM_RESPONSE, etc.) should be logged to the BigQuery table agent_events_v2.
Actual Behavior
Local ([adk web]): ✅ Events are logged to BigQuery correctly
Agent Engine: ❌ No events are logged, no errors raised
Verification Steps Performed
Service Account Permissions Verified: The Reasoning Engine service account (service-{PROJECT_NUMBER}@gcp-sa-aiplatform-re.iam.gserviceaccount.com) has:
roles/bigquery.dataEditor
roles/bigquery.jobUser
BigQuery Access Verified: Added custom tools to the agent that successfully:
Query data from agent_events_v2 table
Insert test rows into agent_events_v2 table
This confirms the service account has proper BigQuery permissions.
Dataset Location Verified: BigQuery dataset is in us-central1, matching the plugin configuration