Skip to content

fix(analytics): log error-bearing tool results as TOOL_ERROR - #7114

Open
Zsanz3 wants to merge 108 commits into
google:mainfrom
Zsanz3:cursor/bqaa-tool-error-result-241d
Open

Zsanz3 wants to merge 108 commits into
google:mainfrom
Zsanz3:cursor/bqaa-tool-error-result-241d

Conversation

@Zsanz3

@Zsanz3 Zsanz3 commented Sep 14, 2026

Copy link
Copy Markdown

Fixes #7112

Summary

BigQueryAgentAnalyticsPlugin.after_tool_callback was logging error-bearing tool results as TOOL_COMPLETED / OK. It now classifies results with isError / error_details as TOOL_ERROR (aligned with on_tool_error_callback).

Changes

  • Detect error_details, isError / is_error; prefer MCP content[0].text for error_message when present
  • Focused unit test with mocked _log_event covering MCP isError and error_details
  • Diff kept tiny; no ReflectAndRetry changes

Tests

pytest tests/unittests/plugins/test_bigquery_agent_analytics_plugin.py -q

@google-cla

google-cla Bot commented Sep 14, 2026

Copy link
Copy Markdown

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.

@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label Sep 15, 2026
@cursor
cursor Bot force-pushed the cursor/bqaa-tool-error-result-241d branch 3 times, most recently from cad66e5 to 864df69 Compare September 16, 2026 22:40
after_tool_callback logged every tool result as TOOL_COMPLETED with
status OK, including MCP CallToolResult isError payloads and results
that carry error_details. Classify those as TOOL_ERROR so status and
error_message match on_tool_error_callback.

Fixes google#7112

Co-authored-by: Zsanz3 <Zsanz3@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/bqaa-tool-error-result-241d branch from 6cd97b5 to 528b7c9 Compare September 21, 2026 07:34
@paulxg12

Copy link
Copy Markdown

Thanks for addressing error-bearing results that would otherwise be logged as successful tool calls. The new error_message is None guard on final-response tools caught my attention too: it prevents a failed call from also producing an AGENT_RESPONSE. Is that case covered by an existing test? If not, a case with the tool in final_response_tool_names and an error-bearing result would help protect that behavior. This is from reading the diff; I haven't run the suite locally.

Covers the error_message is None guard on final_response_tool_names so a failed tool does not also emit AGENT_RESPONSE (requested by paulxg12 on google#7114).
@Zsanz3

Zsanz3 commented Oct 14, 2026

Copy link
Copy Markdown
Author

Thanks @paulxg12 — good catch on the error_message is None guard.

I added a unit test that puts the tool in final_response_tool_names, returns an error-bearing result (error_details), and asserts we get TOOL_ERROR without an AGENT_RESPONSE. Appreciate you reading the diff carefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

request clarification [Status] The maintainer need clarification or more information from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BigQueryAgentAnalyticsPlugin records error-bearing tool results as TOOL_COMPLETED with status OK

5 participants