-
Notifications
You must be signed in to change notification settings - Fork 104
refactor: GH-165 Decoupled the transport layer #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Sun Yuhan <[email protected]>
There was a problem hiding this 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
A2ATransportinterface (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, andA2AClientclasses (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 newA2ATransportinterface instead of directly usingA2AHttpClient, promoting a more modular design. - HTTP Transport Implementation Migration: Existing HTTP client components (
A2AHttpClient,JdkA2AHttpClient) have been moved to a newio.a2a.transport.httppackage and renamed toA2AHttpTransportandJdkA2AHttpTransportrespectively (client/src/main/java/io/a2a/transport/http/A2AHttpTransport.java,client/src/main/java/io/a2a/transport/http/JdkA2AHttpTransport.java).A2AHttpTransportnow extendsA2ATransport, andJdkA2AHttpTransportprovides 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 fromA2ACardResolverandA2AClientinto theJdkA2AHttpTransportimplementation, 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 anA2ATransportparameter, 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
-
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. ↩
There was a problem hiding this 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
A2ATransportAPI 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.
sdk-server-common/src/test/java/io/a2a/server/requesthandlers/JSONRPCHandlerTest.java
Outdated
Show resolved
Hide resolved
…sponse` as a parameter. Signed-off-by: Sun Yuhan <[email protected]>
…Transport`. Signed-off-by: Sun Yuhan <[email protected]>
|
@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? |
|
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! |
|
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? |
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:
A2ATransportas the transport layer for the A2A protocol.HttpClientto instead useA2ATransport(defaulting toJdkA2AHttpTransport).A2AClientthat accepts anA2ATransportparameter.Fixes: #165