Skip to content

feat: Implement extended card support on server side#197

Merged
guglielmo-san merged 15 commits intoa2aproject:mainfrom
guglielmo-san:implement_extended_card_support
Nov 26, 2025
Merged

feat: Implement extended card support on server side#197
guglielmo-san merged 15 commits intoa2aproject:mainfrom
guglielmo-san:implement_extended_card_support

Conversation

@guglielmo-san
Copy link
Member

@guglielmo-san guglielmo-san commented Nov 25, 2025

Description

This PR introduces a more robust implementation of the getAuthenticatedExtendedAgentCard API.
The user may inject in the default_request_handler an AgentCart object or a callback (ExtendedAgentCardProvider) which receives as input parameters the ServerCallContext and returns an AgentCard object.

  • If extendedAgentCardProvider is provided as callback: The logic delegates entirely to the callback. This allows consumers to implement custom authorization check if the user has insufficient permissions.
  • If extendedAgentCardProvider is provided as AgentCard object:
    1. User in context is Authenticated: Returns extendedAgentCard.
    2. User in context is Unauthenticated: Returns the basic agentCard.

Fixes #196 🦕

Release-As: 0.3.6

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @guglielmo-san, 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 pull request significantly enhances the server-side support for extended agent cards by introducing a flexible mechanism to modify these cards based on user authentication and other contextual information. It allows developers to inject custom logic via a new ExtendedCardModifier callback, ensuring that sensitive details in the extended agent card can be dynamically cleared or adjusted before being returned to the client, thereby improving security and customization capabilities.

Highlights

  • New ExtendedCardModifier Type: A new type ExtendedCardModifier has been introduced, allowing custom logic to modify the extendedAgentCard based on the ServerCallContext.
  • getAuthenticatedExtendedAgentCard API Enhancement: The getAuthenticatedExtendedAgentCard method in A2ARequestHandler and DefaultRequestHandler now accepts an optional ServerCallContext parameter, enabling context-aware card modification.
  • Configurable Extended Card Modification: The DefaultRequestHandler constructor now accepts an optional extendedCardModifier callback, enabling server-side customization of the extended agent card based on user authentication levels or other contextual data.
  • Robust Error Handling: Added checks to getAuthenticatedExtendedAgentCard to ensure the agent card explicitly supports extended cards and that an extended card is configured, throwing specific errors otherwise.
  • JSON-RPC Transport Integration: The JSON-RPC transport handler has been updated to correctly route and handle calls to the enhanced agent/getAuthenticatedExtendedCard method, passing the ServerCallContext.
  • Comprehensive Test Coverage: New unit tests have been added to validate the behavior of getAuthenticatedExtendedAgentCard under various scenarios, including unsupported operations, missing configuration, and successful authenticated retrieval with a custom modifier.
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
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 introduces support for an authenticated extended agent card, which can reveal more details to authenticated users. This is primarily achieved by adding an extendedCardModifier callback to the DefaultRequestHandler. The changes look good overall, but I've identified a few critical issues. The ServerCallContext, which contains authentication information, is not being passed to getAuthenticatedExtendedAgentCard in the JSON-RPC transport handler. Additionally, the new tests for this feature contain a bug that makes them pass incorrectly and they are not type-safe. I've also suggested a design improvement to the ExtendedCardModifier signature to make it more robust and useful by providing it with access to the public agent card.

@guglielmo-san guglielmo-san merged commit 45014ac into a2aproject:main Nov 26, 2025
7 checks passed
@guglielmo-san guglielmo-san deleted the implement_extended_card_support branch November 26, 2025 13:46
guglielmo-san added a commit to guglielmo-san/a2a-js that referenced this pull request Nov 27, 2025
# Description

This PR introduces a more robust implementation of the
`getAuthenticatedExtendedAgentCard` API.
The user may inject in the `default_request_handler` an AgentCart object
or a callback (`ExtendedAgentCardProvider`) which receives as input
parameters the `ServerCallContext` and returns an AgentCard object.

- If extendedAgentCardProvider is provided as callback: The logic
delegates entirely to the callback. This allows consumers to implement
custom authorization check if the user has insufficient permissions.
- If extendedAgentCardProvider is provided as AgentCard object:
1. User in context is Authenticated: Returns extendedAgentCard.
2. User in context is Unauthenticated: Returns the basic agentCard.

Fixes a2aproject#196  🦕

Release-As: 0.3.6

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
ishymko added a commit that referenced this pull request Dec 10, 2025
🤖 I have created a release *beep* *boop*
---


## [0.3.6](v0.3.5...v0.3.6)
(2025-12-10)


### Features

* add support for extendedAgentCard on client side
([#234](#234))
([3073376](3073376))
* Add support for extension headers on client side
([#227](#227))
([8c57002](8c57002))
* implement client interceptors
([#223](#223))
([5694c22](5694c22))
* Implement extended card support on server side
([#197](#197))
([45014ac](45014ac))
* implement server http+json
([#142](#142))
([f20e662](f20e662))
* introduce AgentCardResolver
([#225](#225))
([ddaf7de](ddaf7de))
* introduce transport agnostic client
([#198](#198))
([94a9848](94a9848))
* server side support for extensions
([5ef7396](5ef7396))
* support authentication on server side
([#195](#195))
([9872d93](9872d93))


### Bug Fixes

* handle errors occurred in non-blocking sendMessage
([#187](#187))
([e55c0f4](e55c0f4))


### Miscellaneous Chores

* set version to 0.3.6
([#191](#191))
([3f8cea0](3f8cea0))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: Ivan Shymko <ishymko@google.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.

[Feat]: Implement support for getAuthenticatedExtendedAgentCard

2 participants