Skip to content

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

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

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

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.

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
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core [Component] This issue is related to the core interface and implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent Card Builder crashes if agent uses an InstructionProvider

3 participants