Skip to content

fix(a2a): pass documentation_url to AgentCard in AgentCardBuilder#6326

Open
anxkhn wants to merge 1 commit into
google:mainfrom
anxkhn:fix/a2a-agentcard-documentation-url
Open

fix(a2a): pass documentation_url to AgentCard in AgentCardBuilder#6326
anxkhn wants to merge 1 commit into
google:mainfrom
anxkhn:fix/a2a-agentcard-documentation-url

Conversation

@anxkhn

@anxkhn anxkhn commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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):

  • N/A (no existing issue; the change is described below following the issue template structure).

2. Or, if no issue exists, describe the change:

Problem:

AgentCardBuilder accepts a doc_url argument and stores it, but its build()
method passes that value to AgentCard using a keyword named doc_url:

# src/google/adk/a2a/utils/agent_card_builder.py
return AgentCard(
    ...
    doc_url=self._doc_url,
    ...
)

The a2a-sdk AgentCard model has no doc_url field. The documentation URL is
exposed as documentation_url (serialization alias documentationUrl). Because
AgentCard ignores unknown keyword arguments, the value passed as doc_url is
silently dropped, so AgentCardBuilder's doc_url argument has no effect and
generated agent cards never advertise their documentation URL.

Reproduction against the pinned a2a-sdk (>=0.3.4,<0.4; verified on 0.3.26):

from a2a.types import AgentCard

"doc_url" in AgentCard.model_fields            # False
"documentation_url" in AgentCard.model_fields  # True

common = dict(
    name="x", description="d", url="http://localhost/a2a", version="0.0.1",
    capabilities={}, skills=[],
    default_input_modes=["text/plain"], default_output_modes=["text/plain"],
)

AgentCard(doc_url="https://docs.example.com", **common).documentation_url
# -> None   (silently dropped)

AgentCard(documentation_url="https://docs.example.com", **common).documentation_url
# -> 'https://docs.example.com'

Solution:

Pass the stored value to the correct AgentCard keyword, documentation_url, so
the builder's doc_url argument is honored and the card advertises its docs URL:

-          doc_url=self._doc_url,
+          documentation_url=self._doc_url,

The public AgentCardBuilder(..., doc_url=...) argument is intentionally kept as
is, so this is a non-breaking, one-line behavior fix (only the internal keyword
passed to AgentCard changes).

The existing unit test test_build_with_custom_parameters documented the bug by
asserting result.documentation_url is None (with a comment noting the mismatch).
It is updated to assert the URL now round-trips onto AgentCard.documentation_url.

Testing Plan

Unit Tests:

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

Updated test_build_with_custom_parameters in
tests/unittests/a2a/utils/test_agent_card_builder.py: it builds a card with
doc_url="https://docs.example.com" and now asserts
result.documentation_url == "https://docs.example.com".

This is a genuine regression test: reverting only the production line back to
doc_url=self._doc_url makes the assertion fail with
AssertionError: assert None == 'https://docs.example.com'; with the fix it passes.

pytest summary:

$ pytest tests/unittests/a2a/utils/test_agent_card_builder.py -q
77 passed, 17 warnings in 1.08s

$ pytest tests/unittests/a2a -q
362 passed

Manual End-to-End (E2E) Tests:

AgentCardBuilder is experimental and building a card does not require a running
agent, so the behavior is demonstrated directly against a2a-sdk (0.3.26):

BEFORE (doc_url=...)           -> documentation_url = None
AFTER  (documentation_url=...) -> documentation_url = 'https://docs.example.com'

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

AgentCardBuilder is marked experimental (@a2a_experimental). The public
doc_url argument is deliberately left unchanged to avoid an API break; only the
internal keyword handed to AgentCard is corrected.

AgentCardBuilder.build() passed the builder's doc_url value to AgentCard
using the keyword doc_url, but the a2a-sdk AgentCard model has no such
field (it exposes documentation_url, alias documentationUrl). Because
AgentCard ignores unknown keyword arguments, the value was silently
dropped and generated cards never advertised their documentation URL.

Pass the value as documentation_url so the AgentCardBuilder doc_url
argument is honored. Update the unit test to assert the URL now
round-trips onto AgentCard.documentation_url.

Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
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.

1 participant