Skip to content

feat(plugins): add BQAA tests and view columns for AGENT_ERROR / INVOCATION_ERROR#5047

Closed
caohy1988 wants to merge 3 commits intogoogle:mainfrom
caohy1988:feat/bqaa-error-event-tests
Closed

feat(plugins): add BQAA tests and view columns for AGENT_ERROR / INVOCATION_ERROR#5047
caohy1988 wants to merge 3 commits intogoogle:mainfrom
caohy1988:feat/bqaa-error-event-tests

Conversation

@caohy1988
Copy link
Copy Markdown

Summary

Follow-up to #5045. Adds BigQuery Agent Analytics Plugin test coverage and enriches the analytics views for the new AGENT_ERROR and INVOCATION_ERROR event types.

Depends on: #5045 (must merge first)

Changes

View column enrichment (bigquery_agent_analytics_plugin.py):

  • v_agent_error view now extracts error_traceback from content JSON + total_ms from latency
  • v_invocation_error view now extracts error_traceback from content JSON

New tests (test_bigquery_agent_analytics_plugin.py, 4 tests):

Test What it verifies
test_on_agent_error_callback_logs_correctly AGENT_ERROR event has correct error_message, status="ERROR", and error_traceback in content
test_on_run_error_callback_logs_correctly INVOCATION_ERROR event has correct fields and traceback
TestRunErrorCallbackCleanupSafety TraceManager cleanup (clear_stack, context var reset, flush) runs even when _log_event raises during on_run_error_callback
test_error_views_contain_traceback_column View SQL for both error types includes error_traceback extraction

Test plan

  • 4 new tests pass
  • Full BQ plugin suite: 190 passed (was 186), 0 regressions

🤖 Generated with Claude Code

caohy1988 and others added 3 commits March 28, 2026 08:47
Implements RFC google#5044 to close the error callback coverage gap at the
agent and runner levels. Previously, unhandled exceptions escaping
agent execution or runner execution left dangling *_STARTING events
with no terminal error event.

Changes:
- Add on_agent_error_callback and on_run_error_callback to BasePlugin
  (notification-only, exception always re-raised)
- Wire try/except Exception in BaseAgent.run_async() and run_live()
- Wire try/except Exception in Runner._exec_with_plugin()
- Add AGENT_ERROR and INVOCATION_ERROR event types to
  BigQueryAgentAnalyticsPlugin with traceback capture and cleanup
- Keep after_agent_callback and after_run_callback as success-only
  (no semantic change to existing callbacks)
- Catch Exception (not BaseException) to exclude CancelledError/
  KeyboardInterrupt from error callback dispatch

Closes google#4863

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Error callbacks are documented as notification-only (all plugins must
be notified), but were dispatched through _run_callbacks() which
short-circuits on the first non-None return. A buggy plugin returning
a value would prevent subsequent plugins from seeing the error.

Add _run_notification_callbacks() that always iterates all plugins
regardless of return values, and switch run_on_agent_error_callback()
and run_on_run_error_callback() to use it.

Update tests to assert both plugins are always called even when one
returns non-None.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Follow-up to google#5045. Adds BQ plugin-specific test coverage and enriches
the analytics views for AGENT_ERROR and INVOCATION_ERROR events.

Changes:
- Add error_traceback column extraction to v_agent_error and
  v_invocation_error views (JSON_VALUE from content field)
- Add test_on_agent_error_callback_logs_correctly: verifies AGENT_ERROR
  event is logged with correct error_message, status, and traceback
- Add test_on_run_error_callback_logs_correctly: verifies
  INVOCATION_ERROR event is logged with correct fields
- Add TestRunErrorCallbackCleanupSafety: verifies TraceManager cleanup
  runs even when _log_event raises during on_run_error_callback
- Add test_error_views_contain_traceback_column: verifies view SQL
  includes error_traceback extraction

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 28, 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.

@adk-bot adk-bot added the tracing [Component] This issue is related to OpenTelemetry tracing label Mar 28, 2026
@caohy1988 caohy1988 marked this pull request as draft March 28, 2026 17:51
@caohy1988
Copy link
Copy Markdown
Author

Merged into #5045 (commit fd2a947). Closing this standalone PR.

@caohy1988 caohy1988 closed this Mar 28, 2026
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.

2 participants