fix: preserve tenant and protocolVersion from AgentInterface in ClientBuilder#773
Open
Lirons01 wants to merge 1 commit intoa2aproject:mainfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the transport selection logic in ClientBuilder to work directly with AgentInterface objects, allowing for the preservation of metadata like tenant IDs and protocol versions. The findBestClientTransport method was made package-private to support a more comprehensive test suite, which now includes scenarios for both client and server transport preferences. A performance improvement was suggested to replace a nested loop with a map-based lookup when matching client and server transport protocols.
…tBuilder. Also added unit tests around this behavior. Fixes a2aproject#772
7a695e9 to
32d1c89
Compare
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.
Description
ClientBuilder.findBestClientTransport()was creating a new AgentInterface with only protocolBinding and url, discarding tenant and protocolVersion from the matched interface. This broke the intended fallback behavior where the AgentCard's default tenant should be used when no request-level tenant is provided.The fix returns the actual matched AgentInterface from the AgentCard's supportedInterfaces list instead of creating a new one. In addition, I added some tests in order to validate some of this behavior. In order to have the tests actually test this thing, I had to make the
findBestClientTransport()method package-private. LMK if any of this needs edits or does not match the actual intended behavior and I can make appropriate updates!Fixes #772