Skip to content

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

Open
Lirons01 wants to merge 1 commit intoa2aproject:mainfrom
Lirons01:issue-772-tenant-not-preserved-in-client-builder
Open

fix: preserve tenant and protocolVersion from AgentInterface in ClientBuilder#773
Lirons01 wants to merge 1 commit intoa2aproject:mainfrom
Lirons01:issue-772-tenant-not-preserved-in-client-builder

Conversation

@Lirons01
Copy link
Copy Markdown

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
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

2 participants