-
Notifications
You must be signed in to change notification settings - Fork 322
refactor: Refactor client code to support multi-transport interactions and simplify client interfaces #342
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
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 @pstephengoogle, 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 client and server architecture to support multiple communication protocols (JSONRPC, gRPC, RESTful) seamlessly. It introduces a unified Client interface, a ClientFactory for dynamic client creation based on agent capabilities, and a ClientTaskManager for improved task lifecycle management. Additionally, it adds comprehensive server-side support for RESTful API interactions, ensuring consistency with the gRPC definitions.
Highlights
- Multi-Transport Client Architecture: Introduced a new abstract
Clientinterface and implemented concrete clients for JSONRPC, gRPC, and RESTful transports, enabling flexible communication with agents. - Client Factory: Added a
ClientFactoryto automatically generate appropriate client instances based on agent card details and configurable transport preferences. - Client-Side Task Management: Implemented
ClientTaskManagerto streamline the handling and tracking of task lifecycle events received from agents. - Server-Side REST API: Introduced new server-side components (
RESTApplication,A2ARESTFastAPIApplication,RESTHandler) to support RESTful interactions, mirroring gRPC functionality via protobuf definitions. - Simplified Client Interfaces: Refactored existing client methods to align with the new abstract
Clientinterface, simplifying the overall client-side API.
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 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 or fill out our survey 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 pull request introduces a major and well-architected refactoring of the client-side code to support multiple transport protocols (JSON-RPC, gRPC, REST) via a factory pattern. This is a great improvement for modularity and extensibility.
However, the current state of the PR includes several critical issues that must be addressed. There are unresolved git conflict markers in the new REST-related server files, which will prevent the code from running. Additionally, I've found numerous bugs, including NameErrors, AttributeErrors, and TypeErrors in the new client implementations, mostly due to typos, incorrect variable/function names, and misuse of classes.
I've provided detailed comments and suggestions to fix these critical and high-severity issues. Once these are resolved, this will be a solid contribution to the codebase.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
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 pull request introduces a major and well-architected refactoring of the client-side code to support multiple transport protocols (JSON-RPC, gRPC, REST) through a factory pattern. The introduction of a common Client abstract base class and a ClientConfig dataclass greatly improves the architecture, making it more modular and extensible. However, the implementation has several areas that need attention, including critical bugs that could lead to runtime errors, missing features, and incomplete work. Addressing these points will help ensure the new client architecture is robust, complete, and ready for use.
src/a2a/client/client_factory.py
Outdated
| from collections.abc import AsyncGenerator | ||
| from typing import Any, TYPE_CHECKING, Callable | ||
|
|
||
| import httpx | ||
|
|
||
| from httpx_sse import SSEError, aconnect_sse | ||
| from pydantic import ValidationError |
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.
This file contains a number of unused imports. To improve code cleanliness and maintainability, it's best to remove them.
| from collections.abc import AsyncGenerator | |
| from typing import Any, TYPE_CHECKING, Callable | |
| import httpx | |
| from httpx_sse import SSEError, aconnect_sse | |
| from pydantic import ValidationError | |
| from __future__ import annotations | |
| import logging | |
| from typing import Callable | |
| from a2a.utils import Transports | |
| from a2a.client.client import Client, ClientConfig, Consumer | |
| from a2a.client.jsonrpc_client import NewJsonRpcClient | |
| from a2a.client.grpc_client import NewGrpcClient | |
| from a2a.client.rest_client import NewRestfulClient | |
| from a2a.client.middleware import ClientCallInterceptor | |
| from a2a.types import ( | |
| AgentCapabilities, | |
| AgentCard, | |
| ) |
| 'JSONRPCHandler', | ||
| 'RESTHandler', | ||
| 'RequestHandler', | ||
| 'RESTHandler', |
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.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…s and simplify client interfaces (#342) # Description Refactor the client codebase to support automated, configurable, client factory to generate a client based on the agent card details. Adds support for generation of clients based on JSONRPC, gRPC and RESTful interfaces. --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Holt Skinner <[email protected]> Co-authored-by: Holt Skinner <[email protected]>
Description
Refactor the client codebase to support automated, configurable, client factory to generate a client based on the agent card details. Adds support for generation of clients based on JSONRPC, gRPC and RESTful interfaces.