Skip to content

Conversation

@sunyuhan1998
Copy link
Contributor

This PR decouples the transport protocol layer. Considering that, according to the A2A Protocol Specification (https://a2aproject.github.io/A2A/latest/specification/#3-transport-and-format), communication must occur over HTTP(S), I believe we can first decouple the transport layer into a package, rather than rushing to split it into a module (which would face some issues).

The following changes have been made in this PR:

  1. Abstract out A2ATransport as the transport layer for the A2A protocol.
  2. Refactor all existing code that directly used HttpClient to instead use A2ATransport (defaulting to JdkA2AHttpTransport).
  3. Add a new constructor to A2AClient that accepts an A2ATransport parameter.
  4. All test classes have been executed and passed successfully.

Fixes: #165

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.

Summary of Changes

Hello @sunyuhan1998, 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 refactors the A2A client library by decoupling its transport layer. The primary goal is to abstract away the specifics of HTTP communication behind a new A2ATransport interface, making the client more flexible and easier to extend with different transport mechanisms in the future. This change aligns with the A2A Protocol Specification's requirement for HTTP(S) communication while improving the overall architecture and maintainability of the codebase.

Highlights

  • Transport Layer Abstraction: Introduced a new A2ATransport interface (client/src/main/java/io/a2a/transport/A2ATransport.java) to abstract the underlying communication mechanism, allowing for greater flexibility and decoupling from specific HTTP client implementations.
  • Refactoring of Core Client Classes: The A2A, A2ACardResolver, and A2AClient classes (client/src/main/java/io/a2a/A2A.java, client/src/main/java/io/a2a/client/A2ACardResolver.java, client/src/main/java/io/a2a/client/A2AClient.java) have been refactored to depend on the new A2ATransport interface instead of directly using A2AHttpClient, promoting a more modular design.
  • HTTP Transport Implementation Migration: Existing HTTP client components (A2AHttpClient, JdkA2AHttpClient) have been moved to a new io.a2a.transport.http package and renamed to A2AHttpTransport and JdkA2AHttpTransport respectively (client/src/main/java/io/a2a/transport/http/A2AHttpTransport.java, client/src/main/java/io/a2a/transport/http/JdkA2AHttpTransport.java). A2AHttpTransport now extends A2ATransport, and JdkA2AHttpTransport provides the default Java HTTP client implementation for the new interface.
  • Consolidation of Request Logic: Common HTTP request patterns for agent card retrieval, message sending, and streaming (getAgentCard, sendMessage, sendMessageStreaming) have been moved from A2ACardResolver and A2AClient into the JdkA2AHttpTransport implementation, centralizing transport-specific logic.
  • Enhanced Client Instantiation: A new constructor has been added to A2AClient (client/src/main/java/io/a2a/client/A2AClient.java, lines 82-91) that accepts an A2ATransport parameter, enabling users to inject custom transport implementations.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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 PR does a great job of decoupling the transport layer by introducing the A2ATransport interface and moving the HTTP-specific logic into JdkA2AHttpTransport. The code is much cleaner and more modular as a result.

My review focuses on a few key areas for improvement:

  • A performance issue in the new streaming implementation that causes an unnecessary serialization/deserialization cycle.
  • Improving the clarity of the new A2ATransport API by renaming some parameters.
  • Enhancing test code quality by simplifying the test doubles and reducing code duplication.

Overall, this is a solid refactoring. Addressing these points will make the implementation more robust and maintainable.

@sunyuhan1998
Copy link
Contributor Author

sunyuhan1998 commented Jul 8, 2025

Hi @kabir @maeste , what do you think about this? Could you help review this PR? thank you!

@kabir
Copy link
Collaborator

kabir commented Jul 8, 2025

@sunyuhan1998 Hi, just trying to get an alpha release ready and deployed to Maven. This changes the groupId, so I think it is best to wait with this until after that is merged and released

@sunyuhan1998
Copy link
Contributor Author

@sunyuhan1998 Hi, just trying to get an alpha release ready and deployed to Maven. This changes the groupId, so I think it is best to wait with this until after that is merged and released

No problem. By the way, I noticed that in that PR you used a temporary groupId—will it be modified in a separate branch (for releasing the alpha version)? Or are we going to use this groupId in the main branch going forward until the GA release?

@kabir
Copy link
Collaborator

kabir commented Jul 8, 2025

That still needs some discussion, but I think it is probably easier to have it in main, and then we switch back once we have the proper domain registered for the verification of the final group ID

@sunyuhan1998
Copy link
Contributor Author

That still needs some discussion, but I think it is probably easier to have it in main, and then we switch back once we have the proper domain registered for the verification of the final group ID

I see, thank you for your explanation!

@kabir
Copy link
Collaborator

kabir commented Jul 8, 2025

Hi @sunyuhan1998 I have merged the group id change, and done 0.2.3.Alpha1 and 0.2.3.Beta1 releases.

Can you please rebase your branch on the latest?

@sunyuhan1998
Copy link
Contributor Author

Hi @sunyuhan1998 I have merged the group id change, and done 0.2.3.Alpha1 and 0.2.3.Beta1 releases.

Can you please rebase your branch on the latest?

Hi @kabir , I've merged the latest code from the main branch into the current PR. Is that okay?

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]: Decouple transport layer from the core logic, making it an interchangeable component.

2 participants