Skip to content

Conversation

@anmolg1997
Copy link
Contributor

@anmolg1997 anmolg1997 commented Feb 10, 2026

Link to Issue or Description of Change

Problem:

In BigQueryAgentAnalyticsPlugin, before_model_callback and after_model_callback correctly forward **kwargs to _log_event(), but every other callback (before_agent_callback, after_agent_callback, before_tool_callback, after_tool_callback, on_tool_error_callback, on_model_error_callback, on_user_message_callback, before_run_callback, after_run_callback) silently drops them. If you pass custom attributes like customer_id=... they only end up in the BigQuery attributes column for model events — everything else loses them.

Solution:

Added **kwargs to the _log_event() call in all 9 affected callbacks. _log_event already accepts **kwargs so no signature changes needed, just forwarding what's already being received.

Testing Plan

Unit Tests:

$ pytest tests/unittests/plugins/
133 passed, 20 warnings in 23.21s

…allbacks

Only model callbacks (before_model_callback, after_model_callback)
were passing **kwargs through to _log_event(), while all other
callbacks silently dropped them. This meant custom attributes like
`customer_id` passed via **kwargs were only logged for model events,
not for agent, tool, run, or user message events.

Updated the following callbacks to forward **kwargs to _log_event():
- on_user_message_callback
- before_agent_callback / after_agent_callback
- on_model_error_callback
- before_tool_callback / after_tool_callback
- on_tool_error_callback
- before_run_callback / after_run_callback

This ensures custom metadata is consistently serialized into the
BigQuery `attributes` JSON field for all event types.

Fixes google#4330
@google-cla
Copy link

google-cla bot commented Feb 10, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @anmolg1997, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a logging inconsistency within the BigQuery agent analytics plugin. Previously, custom attributes passed as keyword arguments were only captured for model-related events, leading to incomplete data for other critical event types. The changes ensure that all specified callbacks now correctly propagate these custom attributes to the underlying logging mechanism, providing a more comprehensive and consistent data capture for all tracked events.

Highlights

  • Inconsistent **kwargs forwarding fixed: Resolved an issue where only model-related callbacks (before_model_callback, after_model_callback) correctly forwarded **kwargs to the _log_event() function, while other callbacks silently dropped them.
  • Expanded custom attribute logging: Ensured that custom attributes, such as customer_id, passed via **kwargs are now logged for all relevant event types, including agent, tool, run, and user message events, not just model events.
  • Updated 9 BigQuery plugin callbacks: Modified on_user_message_callback, before_agent_callback, after_agent_callback, on_model_error_callback, before_tool_callback, after_tool_callback, on_tool_error_callback, before_run_callback, and after_run_callback to properly forward **kwargs.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/google/adk/plugins/bigquery_agent_analytics_plugin.py
    • Added **kwargs parameter to on_user_message_callback and forwarded them to _log_event.
    • Added **kwargs parameter to before_run_callback and forwarded them to _log_event.
    • Added **kwargs parameter to after_run_callback and forwarded them to _log_event.
    • Added **kwargs parameter to before_agent_callback and forwarded them to _log_event.
    • Added **kwargs parameter to after_agent_callback and forwarded them to _log_event.
    • Added **kwargs parameter to on_model_error_callback and forwarded them to _log_event.
    • Added **kwargs parameter to before_tool_callback and forwarded them to _log_event.
    • Added **kwargs parameter to after_tool_callback and forwarded them to _log_event.
    • Added **kwargs parameter to on_tool_error_callback and forwarded them to _log_event.
Activity
  • No activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot adk-bot added the tracing [Component] This issue is related to OpenTelemetry tracing label Feb 10, 2026
@adk-bot
Copy link
Collaborator

adk-bot commented Feb 10, 2026

Response from ADK Triaging Agent

Hello @anmolg1997, thank you for your contribution!

Before we can merge this PR, you'll need to sign the Contributor License Agreement (CLA). It seems the cla/google check has failed. Please see the comment from the google-cla bot for instructions on how to sign the CLA.

Once the CLA is signed, we can proceed with the review. Thanks!

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an inconsistency in the BigQuery plugin callbacks by ensuring that **kwargs are forwarded to the _log_event method. This fixes a bug where custom attributes were being dropped for several event types. The changes are consistently applied across all relevant callbacks, aligning them with the existing pattern in the file. The docstring updates also improve clarity. The changes are correct and well-implemented.

@anmolg1997 anmolg1997 force-pushed the fix/bigquery-plugin-forward-kwargs-all-callbacks branch from 2ce0268 to bb39cb3 Compare February 10, 2026 14:21
@anmolg1997
Copy link
Contributor Author

I have signed the CLA - @googlebot please verify.

@anmolg1997 anmolg1997 force-pushed the fix/bigquery-plugin-forward-kwargs-all-callbacks branch from bb39cb3 to 9678094 Compare February 10, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tracing [Component] This issue is related to OpenTelemetry tracing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BigQueryAgentAnalyticsPlugin: Pass **kwargs to _log_event for all callbacks (not just model callbacks)

2 participants