feat: Add configureRequest callback to A2A clients - #399
Open
OS-leonardoalmeida wants to merge 7 commits into
Open
feat: Add configureRequest callback to A2A clients#399OS-leonardoalmeida wants to merge 7 commits into
OS-leonardoalmeida wants to merge 7 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces an optional configureRequest callback to the A2AClient constructors in both the A2A and A2A.V0_3 clients, allowing callers to customize outgoing HTTP requests (e.g., for authentication). It also adds comprehensive unit tests to verify this behavior. The feedback suggests ensuring that the newly created HttpRequestMessage in SendAndReadResponseStreamAsync is properly disposed of to avoid potential resource leaks.
Collaborator
|
I like the sound of this PR. I will review shortly once this backlog of pending PRs is cleaned up. Thank you for the contribution. |
xu-shanshan
reviewed
Jun 1, 2026
xu-shanshan
approved these changes
Jun 9, 2026
Author
|
Hi @darrelmiller any news regarding this PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Func<HttpRequestMessage, CancellationToken, Task>? configureRequestparameter to theA2AClientconstructors in both
A2AandA2A.V0_3. When provided, it is invoked for every outgoingHttpRequestMessage(unaryand SSE/streaming) just before
HttpClient.SendAsync, allowing callers to attach authentication headers or other per-request customizations asynchronously.A2AClientto inject per-request headers.Tests
Adds unit tests covering: callback invocation + header propagation on unary requests, invocation + header
propagation on streaming requests, and exception propagation (which prevents the request from being sent).
Refactors the V0_3
MockHttpMessageHandlercapture delegate fromAction<HttpRequestMessage>?toAction<HttpRequestMessage, string?>?. The handler now reads the request body once and passes both the request and the body string to the callback. This was needed because the V0_3 client now disposesHttpRequestMessageviausing, which would otherwise dispose the content before tests could read it.Notes
nulldefault, so existing callers are unaffected (source- andbinary-compatible at the call-site level).
A2A-Version,Accept) so callers can override themif needed.