feat(plugins): add TRANSFER_A2A classification for TransferToAgentTool#5078
Draft
caohy1988 wants to merge 3 commits intogoogle:mainfrom
Draft
feat(plugins): add TRANSFER_A2A classification for TransferToAgentTool#5078caohy1988 wants to merge 3 commits intogoogle:mainfrom
caohy1988 wants to merge 3 commits intogoogle:mainfrom
Conversation
When RemoteA2aAgent is used via sub_agents, the framework creates a TransferToAgentTool that only stores agent names. The analytics plugin returned TRANSFER_AGENT unconditionally for all transfer tools, losing the A2A distinction. This preserves transfer-target origin metadata so analytics can distinguish remote A2A transfers from local ones. Co-Authored-By: Claude Opus 4.6 <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! Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). You can find more information in the "checks" section at the bottom of the pull request. Thanks! |
Exercises before_tool_callback and after_tool_callback with a real TransferToAgentTool and asserts that tool_origin="TRANSFER_A2A" appears in the serialized BigQuery row content, closing the testing gap between the unit-level _resolve_transfer_origin tests and the actual callback wiring. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Spins up an in-process A2A server (ASGI transport), creates an orchestrator with one local sub-agent and one RemoteA2aAgent, runs transfers through BigQueryAgentAnalyticsPlugin with real GCP credentials, and queries BQ to verify tool_origin correctly shows TRANSFER_A2A for remote agents and TRANSFER_AGENT for local agents. Validated against test-project-0728-467323.adk_logs.transfer_a2a_validation. Co-Authored-By: Claude Opus 4.6 <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
target_origin_by_namemetadata toTransferToAgentToolso analytics can distinguish remote A2A transfers from local agent transfersagent_transfer.pyusingisinstance(agent, RemoteA2aAgent)at tool construction time_resolve_transfer_origin()helper in the BQ analytics plugin to refineTRANSFER_AGENT→TRANSFER_A2Aat call time usingtool_args["agent_name"]Fixes #5073
Test plan
test_transfer_to_agent_tool.py— metadata storage (default empty, stored map)test_agent_transfer_system_instructions.py— wiring produces correct origin map with mixed local + A2A sub-agentsTestToolProvenance— all_resolve_transfer_originbranches (remote target, local target, no args, missing key, unknown name)before_tool_callbackandafter_tool_callbackemittool_origin=TRANSFER_A2Ain serialized BQ rowsEnd-to-end validation against real BigQuery
Validation script:
contributing/samples/validate_transfer_a2a/validate.pyArchitecture:
The script starts an in-process A2A server (ASGI transport), creates an orchestrator with both sub-agent types, wires
BigQueryAgentAnalyticsPluginto a real GCP project, sends two prompts (one math, one weather), then queries BQ to verify classification.BQ query results (
test-project-0728-467323.adk_logs.transfer_a2a_validation)TOOL_STARTINGTRANSFER_A2A{"args":{"agent_name":"remote_math_agent"},"tool":"transfer_to_agent","tool_origin":"TRANSFER_A2A"}TOOL_COMPLETEDTRANSFER_A2A{"result":null,"tool":"transfer_to_agent","tool_origin":"TRANSFER_A2A"}TOOL_STARTINGTRANSFER_AGENT{"args":{"agent_name":"local_weather_agent"},"tool":"transfer_to_agent","tool_origin":"TRANSFER_AGENT"}TOOL_COMPLETEDTRANSFER_AGENT{"result":null,"tool":"transfer_to_agent","tool_origin":"TRANSFER_AGENT"}Feature-level validation
target_origin_by_namemetadata stored on toolTOOL_STARTINGrows show differenttool_originper agent — impossible without the metadata mapisinstance(RemoteA2aAgent)population at constructionremote_math_agent→TRANSFER_A2A,local_weather_agent→TRANSFER_AGENT_resolve_transfer_origin()usingtool_args["agent_name"]tool_origin🤖 Generated with Claude Code