Skip to content

fix: preserve tenant and protocolVersion from AgentInterface in ClientBuilder#773

Merged
ehsavoie merged 2 commits intoa2aproject:mainfrom
Lirons01:issue-772-tenant-not-preserved-in-client-builder
Apr 1, 2026
Merged

fix: preserve tenant and protocolVersion from AgentInterface in ClientBuilder#773
ehsavoie merged 2 commits intoa2aproject:mainfrom
Lirons01:issue-772-tenant-not-preserved-in-client-builder

Conversation

@Lirons01
Copy link
Copy Markdown
Contributor

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

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 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
@Lirons01 Lirons01 force-pushed the issue-772-tenant-not-preserved-in-client-builder branch from 7a695e9 to 32d1c89 Compare March 26, 2026 17:31
@@ -24,26 +23,71 @@ public class ClientBuilderTest {

private AgentCard card = AgentCard.builder()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe this whole agent cards building could be simplified in a helper method ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good idea, this looks cleaner now with the helper method IMO

@ehsavoie ehsavoie merged commit adfb93e into a2aproject:main Apr 1, 2026
11 checks passed
@ehsavoie
Copy link
Copy Markdown
Collaborator

ehsavoie commented Apr 1, 2026

thanks @Lirons01

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.

[Bug]: ClientBuilder does not preserve tenant or protocolVersion when selecting transport

3 participants