Skip to content

BigQuery Agent Analytics Plugin - crashes Agent Execution when using Workflow Agent #4076

@evekhm

Description

@evekhm

Following exception happens when using ParallelAgent/Sequential agents along with BigQueryPlugin (it expects "instruction" field for Workflow Agent, that does not have such field.

2026-01-05 11:09:59,641 - ERROR - plugin_manager.py:304 - Error in plugin 'bigquery_agent_analytics' during 'before_agent_callback' callback: 'ParallelAgent' object has no attribute 'instruction'
Traceback (most recent call last):
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/plugins/plugin_manager.py", line 289, in _run_callbacks
    result = await callback_method(**kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/plugins/bigquery_agent_analytics_plugin.py", line 1739, in before_agent_callback
    "AGENT_STARTING", callback_context, raw_content=agent.instruction
                                                    ^^^^^^^^^^^^^^^^^
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/pydantic/main.py", line 1026, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'ParallelAgent' object has no attribute 'instruction'
2026-01-05 11:09:59,657 - ERROR - adk_web_server.py:1509 - Error in event_generator: Error in plugin 'bigquery_agent_analytics' during 'before_agent_callback' callback: 'ParallelAgent' object has no attribute 'instruction'
Traceback (most recent call last):
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/plugins/plugin_manager.py", line 289, in _run_callbacks
    result = await callback_method(**kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/plugins/bigquery_agent_analytics_plugin.py", line 1739, in before_agent_callback
    "AGENT_STARTING", callback_context, raw_content=agent.instruction
                                                    ^^^^^^^^^^^^^^^^^
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/pydantic/main.py", line 1026, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'ParallelAgent' object has no attribute 'instruction'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/cli/adk_web_server.py", line 1499, in event_generator
    async for event in agen:
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/runners.py", line 505, in run_async
    async for event in agen:
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/runners.py", line 493, in _run_with_trace
    async for event in agen:
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/runners.py", line 722, in _exec_with_plugin
    async for event in agen:
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/runners.py", line 482, in execute
    async for event in agen:
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/agents/base_agent.py", line 294, in run_async
    async for event in agen:
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/agents/llm_agent.py", line 460, in _run_async_impl
    async for event in agen:
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 370, in run_async
    async for event in agen:
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 457, in _run_one_step_async
    async for event in agen:
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 569, in _postprocess_async
    async for event in agen:
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 716, in _postprocess_handle_function_calls_async
    async for event in agen:
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/agents/base_agent.py", line 288, in run_async
    if event := await self._handle_before_agent_callback(ctx):
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/agents/base_agent.py", line 446, in _handle_before_agent_callback
    await ctx.plugin_manager.run_before_agent_callback(
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/plugins/plugin_manager.py", line 160, in run_before_agent_callback
    return await self._run_callbacks(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/evekhm/projects/adk/agent-starter-pack-project/ek-test/.venv/lib/python3.12/site-packages/google/adk/plugins/plugin_manager.py", line 305, in _run_callbacks
    raise RuntimeError(error_message) from e
RuntimeError: Error in plugin 'bigquery_agent_analytics' during 'before_agent_callback' callback: 'ParallelAgent' object has no attribute 'instruction'

Here is the sample code:

import os
import time

import google.auth
import google.auth
from google.adk.agents import LlmAgent
from google.adk.agents import ParallelAgent
from google.adk.apps import App
from google.adk.plugins.bigquery_agent_analytics_plugin import BigQueryAgentAnalyticsPlugin, BigQueryLoggerConfig
from google.genai import types

_, project_id = google.auth.default()

# --- Configuration ---
PROJECT_ID = os.environ.get("GOOGLE_CLOUD_PROJECT", project_id)
DATASET_ID = os.environ.get("BIG_QUERY_DATASET_ID", "logging")
BQ_LOCATION = os.environ.get("GOOGLE_CLOUD_LOCATION", "US") # default location is US in the plugin
LOCATION = os.environ.get("GOOGLE_CLOUD_LOCATION", "global") # required for gemini-3 preview
MODEL_ID = os.environ.get("MODEL_ID", "gemini-3-pro-preview")

# --- CRITICAL: Set environment variables BEFORE Gemini instantiation ---
os.environ['GOOGLE_CLOUD_PROJECT'] = PROJECT_ID
os.environ['GOOGLE_CLOUD_LOCATION'] = LOCATION
os.environ['GOOGLE_GENAI_USE_VERTEXAI'] = 'True'

# --- Initialize the Plugin with Config ---
bq_config = BigQueryLoggerConfig(
    enabled=True,
    # event_allowlist=["LLM_REQUEST", "LLM_RESPONSE"], # Only log these events
    max_content_length=500 * 1024, # 500 KB limit for inline text
    batch_size=1, # Default is 1 for low latency, increase for high throughput
    shutdown_timeout=10.0
)

bq_logging_plugin = BigQueryAgentAnalyticsPlugin(
    project_id=PROJECT_ID,
    dataset_id=DATASET_ID,
    table_id="agent_events_v2", # default table name is agent_events_v2
    config=bq_config,
    location=BQ_LOCATION
)


def sleep(seconds: int) -> None:
    """Sleeps for one minute."""
    """Pauses the execution for a specified number of seconds.

    Args:
        seconds: The number of seconds to sleep.
    """
    print(f"Going to sleep for {seconds} seconds...")
    time.sleep(seconds)
    print(f"Finished sleeping")


def build_parallel_team(agent_index: int) -> LlmAgent:
    """Creates a dedicated analysis team for a specific latency dimension."""
    # 1. Primer Agent
    primer = LlmAgent(
        name=f"sleep_sub_agent_{agent_index}",
        model=MODEL_ID,
        description="A simple agent that can sleep.",
        instruction="You are a helpful assistant. If asked to sleep, use the sleep_one_minute tool.",
        generate_content_config=types.GenerateContentConfig(
            temperature=0,
            labels={"llm.agent.name": f"sleep_sub_agent_{agent_index}"}
        ),
        tools=[sleep]
    )
    return primer


root_agent = LlmAgent(
    name="hello_world_agent",
    model=MODEL_ID,
    description="A hello world agent that coordinates a sleeping sub-agent.",
    instruction="You are a hello world coordinator. If the user asks for sleep, delegate to the sleep_sub_agent.",
    sub_agents=[ParallelAgent(
        name="sleep_sub_agent",
        description="Runs multiple agents in parallel to execute sleep action by the user.",
        sub_agents=[build_parallel_team(ix) for ix in range(1, 4)])]
)

app = App(root_agent=root_agent, name="app", plugins=[bq_logging_plugin],) #THIS FAILS
#app = App(root_agent=root_agent, name="app") # THIS WORKS

Metadata

Metadata

Labels

bq[Component] This issue is related to Big Query integration

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions