Skip to content

feat: Add support for extension headers on client side#227

Merged
guglielmo-san merged 37 commits intoa2aproject:mainfrom
guglielmo-san:infer_extensions_in_headers
Dec 5, 2025
Merged

feat: Add support for extension headers on client side#227
guglielmo-san merged 37 commits intoa2aproject:mainfrom
guglielmo-san:infer_extensions_in_headers

Conversation

@guglielmo-san
Copy link
Member

Description

This PR implements the support for extensions on client side

Fixes #170 🦕

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 client-side capabilities by introducing a robust interception framework and explicit support for extension headers. The new interceptor pattern allows for greater control and customization of client-server interactions, while the extension header support enables more flexible communication protocols. These changes improve the extensibility and adaptability of the client library.

Highlights

  • Client-side Interceptors: Introduced a new interception mechanism allowing custom logic to be executed before and after client method calls. This enables modification of requests, responses, and options, as well as early returns.
  • Extension Headers Support: Added explicit support for extension headers on the client side, allowing clients to specify a list of extension URIs that will be included in HTTP requests.
  • Refactored RequestOptions: The RequestOptions interface has been moved and enhanced to include extensions and a context map, providing more flexibility for request customization.
  • Comprehensive Interceptor Testing: New tests have been added to validate the interceptor functionality, covering various scenarios including request/response modification, early exits, and interception of streaming calls.
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 a powerful interceptor mechanism for client-side calls, which is a great addition for extensibility. The implementation is well-structured, with clear separation of concerns in the new interceptors.ts file and good test coverage for the new functionality. I've found a few areas for improvement: one is a minor API design suggestion to make RequestOptions.context optional, another is a bug fix for the non-streaming fallback in sendMessageStream where after interceptors were not being called, and finally a suggestion to refactor some duplicated code in the streaming methods to improve maintainability. Overall, this is a solid contribution.

@guglielmo-san guglielmo-san changed the title Feat: Add support for extension headers on client side feat: Add support for extension headers on client side Dec 3, 2025
@guglielmo-san guglielmo-san requested a review from ishymko December 3, 2025 14:59
@guglielmo-san
Copy link
Member Author

/gemini review

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 adds support for extension headers on the client side. The changes include updating the RequestOptions interface, adding helper functions to generate and parse extension headers, and integrating this logic into the JsonRpcTransport. A new test file is also added to verify the functionality. The implementation is solid, but I have identified a potential bug in the header parsing logic and a minor improvement for type safety in the tests. Overall, great work on implementing this feature.

@guglielmo-san
Copy link
Member Author

/gemini review

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 client-side extension headers. It adds a serviceParameters option to requests, which is then used by the JSON-RPC transport to include custom headers. The response headers are also parsed for activated extensions. The changes are well-tested. I've found one potential issue regarding the order of properties when constructing request headers, which could lead to important headers being unintentionally overridden. My review includes a suggestion to fix this.

@guglielmo-san guglielmo-san enabled auto-merge (squash) December 5, 2025 11:27
@guglielmo-san guglielmo-san merged commit 8c57002 into a2aproject:main Dec 5, 2025
6 checks passed
@guglielmo-san guglielmo-san deleted the infer_extensions_in_headers branch December 5, 2025 12:45
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]: Add support for extensions

2 participants