Skip to content

Conversation

@jmesnil
Copy link
Collaborator

@jmesnil jmesnil commented Dec 10, 2025

…the client's consumers

and its streamingErrorHandler

The code was already doing that down the path but this simplifies the code as the consumers and streamingErrorhandler can be validated from the top of the API

Add a bunch of @nullable & @nonnull to clarify the API contract

This fixes #526

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jmesnil, 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 streamlines the client-side API for sending messages and resubscribing to event streams. The primary goal is to ensure that default consumer lists and streaming error handlers, configured at the client level, are automatically applied when these operations are invoked without explicit overrides. This change simplifies the API's usage and improves code maintainability by centralizing handler validation and application. Additionally, the introduction of nullability annotations (@NonNull, @Nullable) clarifies the expected input and output contracts, enhancing code robustness and readability.

Highlights

  • API Contract Clarification: Introduced @NonNull and @Nullable annotations across various methods and fields to explicitly define the API contract for nullability, enhancing code robustness and readability.
  • Centralized Consumer/Error Handling: Refactored sendMessage and resubscribe methods to consistently utilize the client's default consumers and streaming error handler when not explicitly provided, simplifying the API and internal logic.
  • Code Simplification: Removed redundant method overloads and internal helper methods (consume from AbstractClient, resubscribeToTask from Client) by consolidating logic into fewer, more comprehensive methods.
  • New Test Coverage: Added a new test case (testResubscribeExistingTaskSuccessWithClientConsumers) to validate the updated resubscribe functionality when using client-configured consumers.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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 pull request is a nice refactoring that simplifies the client API. By making the sendMessage and resubscribe methods use the client's configured consumers and error handler by default, you've reduced complexity and removed the need for null-checks and fallbacks deeper in the call stack. The restructuring of abstract and concrete methods in AbstractClient is a good design improvement. The consistent addition of @NonNull and @Nullable annotations clarifies the API contract, and the new test case for resubscribe is a valuable addition. I have one minor suggestion regarding Javadoc consistency to further improve clarity.

* used if the streaming approach is used
* @param metadata the optional metadata to include when sending the message
* @param context optional client call context for the request (may be {@code null})
* @param context optional client call context for the request
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The Javadoc for the @Nullable parameter context has been updated to remove the (may be {@code null}) clarification. While the @Nullable annotation is present, explicitly mentioning nullability in the Javadoc is a good practice for clarity, especially for developers whose tools might not display nullability annotations. This same issue is present for other updated method signatures in this file (e.g., resubscribe). Consider re-adding this clarification for consistency and improved readability.

Suggested change
* @param context optional client call context for the request
* @param context optional client call context for the request (may be {@code null})

…the client's consumers

and its streamingErrorHandler

The code was already doing that down the path but this simplifies the code
as the consumers and streamingErrorhandler can be validated from the
top of the API

Add a bunch of @nullable & @nonnull to clarify the API contract

This fixes a2aproject#526

Signed-off-by: Jeff Mesnil <jmesnil@ibm.com>
@jmesnil jmesnil force-pushed the 526_resubscribe_with_consumers branch from a6d3664 to 23f1f89 Compare December 10, 2025 14:10
@jmesnil
Copy link
Collaborator Author

jmesnil commented Dec 10, 2025

/gemini review

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 pull request refactors the AbstractClient and Client classes to streamline the handling of consumers and streaming error handlers. The changes simplify the API by ensuring that sendMessage and resubscribe methods without explicit consumer or error handler parameters correctly utilize the client's default configured ones. The introduction of @NonNull and @Nullable annotations significantly clarifies the API contract, improving code readability and maintainability. A new test case has been added to validate the updated resubscription behavior, which is a good practice.

@ehsavoie ehsavoie merged commit 46b1b0a into a2aproject:main Dec 12, 2025
10 checks passed
kabir pushed a commit to kabir/a2a-java that referenced this pull request Dec 23, 2025
a2aproject#528)

…the client's consumers

and its streamingErrorHandler

The code was already doing that down the path but this simplifies the
code as the consumers and streamingErrorhandler can be validated from
the top of the API

Add a bunch of @nullable & @nonnull to clarify the API contract

This fixes a2aproject#526

Signed-off-by: Jeff Mesnil <jmesnil@ibm.com>
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.

[Task]: Improve subscribe and sendMessage contract from the Client API

2 participants