Skip to content

fix(a2a): Support instruction providers in cards - #6451

Open
March-77 wants to merge 1 commit into
google:mainfrom
March-77:agent/support-instruction-provider-cards
Open

fix(a2a): Support instruction providers in cards#6451
March-77 wants to merge 1 commit into
google:mainfrom
March-77:agent/support-instruction-provider-cards

Conversation

@March-77

Copy link
Copy Markdown
Contributor

Link to Issue or Description of Change

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

Problem:
LlmAgent.instruction and global_instruction may be runtime InstructionProvider callables, but the static Agent Card builder passed them to string regexes for description and example extraction. Card generation therefore failed before the A2A agent could start.

Solution:
Only include string instructions in static card descriptions and examples. Providers require a real ReadonlyContext, so card generation leaves them unexecuted while preserving the agent description, default description, and existing string-instruction behavior.

Testing Plan

Unit Tests:

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

Passed:

  • pytest tests/unittests/a2a/utils -q: 110 passed, 2 skipped
  • Sync, async, and global provider cases build complete cards and assert each callback is called zero times
  • Ruff, isort, Pyink, addlicense, and ADK compliance checks on both changed files
  • uv build: sdist and wheel built successfully

The repository-wide Windows run reached 9,059 passed, 66 skipped, and 18 xfailed; 40 unrelated tests failed on Windows path-length, shell, line-ending, and filesystem integration assumptions. The changed A2A suite is fully green. The pre-commit check-new-py-prefix wrapper also expects /bin/bash and cannot launch natively on Windows; no files were added, and the script passes when invoked directly with Git Bash.

Manual End-to-End (E2E) Tests:

Ran the issue's public LlmAgent + AgentCardBuilder.build() flow with an instruction provider. Before the change it raised RuntimeError wrapping TypeError; after the change it returns a card without invoking the provider.

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. (Related tests pass; see the Windows-only full-suite limitations above.)
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules. (No dependent changes.)

Additional context

The Agent Card is static and has no session or invocation context. Skipping runtime providers avoids executing user code with fabricated context and avoids exposing context-dependent instructions in card metadata.

@google-cla

google-cla Bot commented Jul 22, 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.

@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Jul 22, 2026
@March-77
March-77 marked this pull request as ready for review July 23, 2026 03:37
@rohityan

Copy link
Copy Markdown
Collaborator

Hi @March-77 , Thank you for your contribution! It appears you haven't yet signed the Contributor License Agreement (CLA). Please visit https://cla.developers.google.com/ to complete the signing process. Once the CLA is signed, we'll be able to proceed with the review of your PR. Thank you!

@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label Jul 23, 2026
@rohityan
rohityan force-pushed the agent/support-instruction-provider-cards branch 2 times, most recently from 1157b06 to cf8d1e1 Compare July 27, 2026 17:58
@rohityan rohityan added a2a [Component] This issue is related a2a support inside ADK. needs review [Status] The PR/issue is awaiting review from the maintainer and removed request clarification [Status] The maintainer need clarification or more information from the author core [Component] This issue is related to the core interface and implementation labels Jul 27, 2026
@rohityan
rohityan requested a review from wukath July 27, 2026 21:39
@rohityan

Copy link
Copy Markdown
Collaborator

Hi @March-77 , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share.

@rohityan

Copy link
Copy Markdown
Collaborator

Hi @wukath , can you please review this. LGTM

@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Jul 28, 2026
Agent cards are static and have no ReadonlyContext, so passing callable instructions into description or example regexes crashes card generation. Include only static strings and leave runtime providers unexecuted.

Fixes google#6450
@March-77
March-77 force-pushed the agent/support-instruction-provider-cards branch from cf8d1e1 to d8d24c5 Compare July 28, 2026 02:45
@March-77

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I rebased this PR onto the latest main to address the unrelated mypy baseline drift. The functional patch is unchanged (range-diff is identical), and the PR still contains the same single commit touching the same two files. The related tests still pass locally. The new workflow run is currently awaiting maintainer approval.

@gammer24 gammer24 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes

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

Labels

a2a [Component] This issue is related a2a support inside ADK. core [Component] This issue is related to the core interface and implementation needs review [Status] The PR/issue is awaiting review from the maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent Card Builder crashes if agent uses an InstructionProvider

5 participants