Skip to content

refactor(client): move agent card signature verification to BaseClient#793

Merged
guglielmo-san merged 3 commits intoa2aproject:1.0-devfrom
guglielmo-san:guglielmoc/fix_agent_card_signature
Mar 9, 2026
Merged

refactor(client): move agent card signature verification to BaseClient#793
guglielmo-san merged 3 commits intoa2aproject:1.0-devfrom
guglielmo-san:guglielmoc/fix_agent_card_signature

Conversation

@guglielmo-san
Copy link
Copy Markdown
Member

@guglielmo-san guglielmo-san commented Mar 9, 2026

This PR refactors the signature verification logic for Extended Agent Cards to be handled at the client level (BaseClient) rather than being duplicated across each individual transport implementation (GrpcTransport, JsonRpcTransport, RestTransport).

Changes:

  • BaseClient: Added signature verification step and state mutation logic (self._card = card) inside get_extended_agent_card().
  • Transports (gRPC, JSON-RPC, REST, TenantDecorator): Removed the signature_verifier parameter from get_extended_agent_card().
  • Removed internal caching mechanism and state (self.agent_card, self._needs_extended_card) from the get_extended_agent_card() flow.

… signature verification from client transports.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This refactoring centralizes the signature verification process for extended agent cards within the BaseClient, streamlining the client architecture by removing redundant logic from individual transport layers. This change simplifies the get_extended_agent_card methods in transports and enhances maintainability by consolidating a critical security step.

Highlights

  • Centralized Signature Verification: Moved the signature verification logic for Extended Agent Cards from individual transport implementations (gRPC, JSON-RPC, REST) to the BaseClient's get_extended_agent_card method, ensuring a single point of control for this critical step.
  • Simplified Transport Interfaces: Removed the signature_verifier parameter from the get_extended_agent_card method across all transport implementations (GrpcTransport, JsonRpcTransport, RestTransport, TenantDecorator) and the Client class, simplifying their interfaces.
  • Removed Redundant Caching: Eliminated internal caching mechanisms and state (self.agent_card, self._needs_extended_card) related to extended agent cards within the transport layers, as this state is now managed at the BaseClient level.
  • Updated Integration Tests: Adjusted integration tests to align with the refactored signature verification and caching logic, removing outdated assertions and modifying how the signature_verifier is invoked.
Changelog
  • src/a2a/client/base_client.py
    • Moved signature verification logic from transport layer to BaseClient's get_extended_agent_card method.
  • src/a2a/client/client.py
    • Removed signature_verifier parameter from get_extended_agent_card.
  • src/a2a/client/transports/base.py
    • Removed Callable import.
    • Removed signature_verifier parameter from get_extended_agent_card.
  • src/a2a/client/transports/grpc.py
    • Removed _needs_extended_card initialization.
    • Removed signature_verifier parameter and associated verification/caching logic from get_extended_agent_card.
    • Added an early return for cards without extended capabilities.
  • src/a2a/client/transports/jsonrpc.py
    • Removed Callable import.
    • Removed _needs_extended_card initialization.
    • Removed signature_verifier parameter and associated verification/caching logic from get_extended_agent_card.
  • src/a2a/client/transports/rest.py
    • Removed Callable import.
    • Removed _needs_extended_card initialization.
    • Removed signature_verifier parameter and associated verification/caching logic from get_extended_agent_card.
  • src/a2a/client/transports/tenant_decorator.py
    • Removed Callable import.
    • Removed signature_verifier parameter from get_extended_agent_card.
  • src/a2a/compat/v0_3/grpc_transport.py
    • Removed signature_verifier parameter and associated verification logic from get_extended_agent_card.
  • tests/integration/test_client_server_integration.py
    • Removed assertions related to transport.agent_card and _needs_extended_card.
    • Adjusted get_extended_agent_card calls to remove signature_verifier argument and explicitly call the verifier.
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the agent card signature verification by moving the logic from individual transports to the BaseClient. The changes are mostly correct and align with the goal of centralizing this logic.

I've found a couple of issues:

  1. A type signature mismatch in Client and BaseClient that would likely fail mypy checks.
  2. A critical bug in GrpcTransport that could lead to a runtime AttributeError when handling an agent card.

I've provided specific comments and suggestions to address these points. Once fixed, the refactoring will be much more robust.

Comment thread src/a2a/client/transports/grpc.py Outdated
Comment thread src/a2a/client/client.py
@guglielmo-san guglielmo-san marked this pull request as ready for review March 9, 2026 14:23
@guglielmo-san guglielmo-san requested a review from a team as a code owner March 9, 2026 14:23
@guglielmo-san guglielmo-san requested a review from ishymko March 9, 2026 14:23
@ishymko ishymko changed the title refactor(Client): move agent card signature verification to BaseClient refactor(client): move agent card signature verification to BaseClient Mar 9, 2026
@guglielmo-san guglielmo-san merged commit 13d0106 into a2aproject:1.0-dev Mar 9, 2026
8 checks passed
@guglielmo-san guglielmo-san deleted the guglielmoc/fix_agent_card_signature branch March 9, 2026 15:54
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.

3 participants