Skip to content

fix(a2a): load remote agent cards before transfer prompts#6234

Open
gyx09212214-prog wants to merge 1 commit into
google:mainfrom
gyx09212214-prog:fix-remote-a2a-agent-card-description
Open

fix(a2a): load remote agent cards before transfer prompts#6234
gyx09212214-prog wants to merge 1 commit into
google:mainfrom
gyx09212214-prog:fix-remote-a2a-agent-card-description

Conversation

@gyx09212214-prog

Copy link
Copy Markdown

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:
RemoteA2aAgent currently resolves its agent card only when the remote agent is invoked. That means the root agent's transfer prompt can be built before the remote card description is available, creating a cold-start routing problem. If a local description is supplied, the current blank-description guard also prevents the resolved agent-card description from ever becoming the routing description.

Agent-card skills and examples are also useful delegation context, but they are not surfaced in the transfer prompt before delegation.

Solution:
This PR makes the resolved agent card the source of transfer context for RemoteA2aAgent by building the agent description from the card description plus its skills, tags, and examples. The transfer request processor now resolves transfer targets that expose _ensure_resolved() before building transfer instructions, so remote target descriptions are available before the LLM decides where to delegate.

Resolution is done concurrently with asyncio.gather() so multiple remote targets do not serialize card lookup.

Duplicate check:
Before opening this PR, I searched existing PRs for:

  • 4064 RemoteA2aAgent agent card description
  • remote agent card description skills examples
  • _ensure_resolved agent_card description
  • exact head branch: gyx09212214-prog:fix-remote-a2a-agent-card-description

No open or closed PR with the same #4064 fix scope was found. The related older PR #3297 is closed and unmerged; the linked commit that closed it only refactored transfer instruction building and does not resolve #4064's cold-start agent-card lookup behavior.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Passed locally:

.\.venv\Scripts\python -m pytest tests\unittests\agents\test_remote_a2a_agent.py tests\unittests\flows\llm_flows\test_agent_transfer_system_instructions.py -q

Result:

113 passed, 120 warnings

Also ran:

.\.venv\Scripts\python -m py_compile src\google\adk\agents\remote_a2a_agent.py src\google\adk\flows\llm_flows\agent_transfer.py tests\unittests\agents\test_remote_a2a_agent.py tests\unittests\flows\llm_flows\test_agent_transfer_system_instructions.py
$env:PIP_INDEX_URL='https://pypi.org/simple'; $env:SKIP='addlicense,check-new-py-prefix'; .\.venv\Scripts\pre-commit run --files src\google\adk\agents\remote_a2a_agent.py src\google\adk\flows\llm_flows\agent_transfer.py tests\unittests\agents\test_remote_a2a_agent.py tests\unittests\flows\llm_flows\test_agent_transfer_system_instructions.py

pre-commit passed for ruff, isort, pyink, trailing whitespace, and end-of-file hooks. I skipped the two local bash-only hooks (addlicense, check-new-py-prefix) because /bin/bash is not available in this Windows environment; no new Python files were added.

git diff --check

No whitespace errors.

Manual End-to-End (E2E) Tests:

Not run. The regression is covered by unit tests for both direct RemoteA2aAgent resolution and transfer-prompt construction before delegation.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

This keeps the behavior narrow to transfer metadata resolution and RemoteA2aAgent description synchronization. It does not add agent-card refresh policy; resolved agents continue to use the existing _ensure_resolved() lifecycle.

@google-cla

google-cla Bot commented Jun 28, 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.

@gyx09212214-prog gyx09212214-prog marked this pull request as ready for review June 28, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A2A remote agent client does not load description from agent card on start up

1 participant