fix: classify TransferToAgentTool transfers to RemoteA2aAgent as TRANSFER_A2A#5317
Closed
caohy1988 wants to merge 2 commits intogoogle:mainfrom
Closed
fix: classify TransferToAgentTool transfers to RemoteA2aAgent as TRANSFER_A2A#5317caohy1988 wants to merge 2 commits intogoogle:mainfrom
caohy1988 wants to merge 2 commits intogoogle:mainfrom
Conversation
…SFER_A2A When a RemoteA2aAgent is registered via sub_agents, the BigQuery analytics plugin now correctly classifies transfers to it as "TRANSFER_A2A" instead of the generic "TRANSFER_AGENT". Classification is call-level: a single TransferToAgentTool with mixed local and A2A targets produces the correct label per invocation based on the selected agent_name. The fix is localized to the plugin — no changes to TransferToAgentTool or the ADK core. The plugin resolves the target agent at runtime via the invocation context's agent tree. Fixes google#5073 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
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. |
Collaborator
|
Response from ADK Triaging Agent Hello @caohy1988, thank you for creating this PR! It looks like you haven't signed the Contributor License Agreement (CLA) yet. Before we can review your pull request, you'll need to sign the CLA. This information will help reviewers to review your PR more efficiently. Thanks! |
…_callback The error callback path was still calling _get_tool_origin(tool) without the tool_args and tool_context needed for call-level A2A classification, leaving failed remote A2A transfers misclassified as TRANSFER_AGENT. Adds a callback-level regression test that exercises on_tool_error_callback with a TransferToAgentTool targeting a RemoteA2aAgent and asserts the logged tool_origin is TRANSFER_A2A. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5073
When a
RemoteA2aAgentis registered viasub_agents=[], theBigQueryAgentAnalyticsPluginnow correctly classifies transfers to it asTRANSFER_A2Ainstead of the genericTRANSFER_AGENT.Implementation Approach
Per the architectural decision in the issue thread, the fix is localized entirely to the BigQuery analytics plugin — no changes to
TransferToAgentToolor the ADK core.The plugin resolves the transfer origin at call-level in
before_tool_callback/after_tool_callback:TransferToAgentToolinstancesagent_namefromtool_argstool_context._invocation_context.agentTRANSFER_A2Aif the target is aRemoteA2aAgent, otherwiseTRANSFER_AGENTThis means a single
TransferToAgentToolwith mixed local and A2A targets produces the correct label per invocation.Changes
bigquery_agent_analytics_plugin.py: Added_find_transfer_target()helper and extended_get_tool_origin()with optionaltool_args/tool_contextparameters for call-level transfer classificationtest_bigquery_agent_analytics_plugin.py: Added 5 new test cases covering A2A sub-agent, local sub-agent, A2A peer, mixed-target per-call classification, and fallback without argsClassification Table
AgentTool(local agent)SUB_AGENT(unchanged)AgentTool(RemoteA2aAgent)A2A(unchanged)FunctionToolLOCAL(unchanged)McpToolMCP(unchanged)TransferToAgentToolTRANSFER_AGENT(unchanged)TransferToAgentToolRemoteA2aAgentTRANSFER_A2A(new)Test plan
RemoteA2aAgentsub-agent →TRANSFER_A2ATRANSFER_AGENTRemoteA2aAgentpeer →TRANSFER_A2ATRANSFER_AGENTwhen notool_args/tool_contextprovided🤖 Generated with Claude Code