feat: Make RequestContext taskId and contextId nullable.#642
feat: Make RequestContext taskId and contextId nullable.#642kabir merged 5 commits intoa2aproject:mainfrom
Conversation
This is possible by moving the generation of IDs when not set into the builder, and making sure the builder is used.
Summary of ChangesHello @kabir, 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 refactors the Highlights
Changelog
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request refactors RequestContext to make taskId and contextId non-nullable, moving the ID generation and validation logic into the RequestContext.Builder. This is a great change that improves the robustness and predictability of the RequestContext. While reviewing, I found a couple of issues in the new build() method's logic that could lead to incorrect behavior and data inconsistencies. I've provided a detailed comment with a suggested refactoring to address these points. The rest of the changes, including the updates to tests, look good and align with the goal of the pull request.
server-common/src/main/java/io/a2a/server/agentexecution/RequestContext.java
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request is a great improvement. It refactors the RequestContext to ensure taskId and contextId are always non-null, moving the ID generation and validation logic into the RequestContext.Builder. This simplifies the RequestContext class, making it an immutable data holder and improving the overall design. The tests have been diligently updated to reflect these changes.
I've found one significant bug in the new builder logic related to multi-tenancy, and I've also suggested a refactoring of the build() method to improve its clarity and maintainability. Please see the detailed comment.
server-common/src/main/java/io/a2a/server/agentexecution/RequestContext.java
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request is a nice refactoring of the RequestContext class. Moving the construction logic into a Builder and making the fields final greatly improves the class's immutability and makes it easier to reason about. The ID generation logic is now cleanly centralized. The test suite has been updated accordingly, and new tests have been added to cover the new builder logic.
I've found one issue in a new test case, testBuilderPreservesTenantWhenUpdatingMessage, which doesn't correctly verify the behavior it's intended to test. My review comment provides details on the issue and a suggestion for how to fix it.
server-common/src/test/java/io/a2a/server/agentexecution/RequestContextTest.java
Outdated
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request successfully refactors the RequestContext class to ensure that taskId and contextId are always non-nullable. This is achieved by introducing a dedicated Builder class that handles the generation and validation of these IDs, centralizing this logic and improving the robustness of RequestContext instances. The changes are well-implemented, and the comprehensive updates to the test suite effectively validate the new behavior, including ID generation, validation, and the preservation of other parameters like tenant during message updates. This is a significant improvement to the API's clarity and reliability.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces significant improvements to the RequestContext class by making taskId and contextId non-nullable and ensuring their generation and validation are handled exclusively by a new Builder class. This refactoring centralizes ID management, enhances the robustness of RequestContext objects, and enforces a more controlled construction process. The constructor of RequestContext is now private, correctly mandating the use of the builder. Additionally, a new getTenant() method has been added, and the test suite has been thoroughly updated with new tests covering ID generation, preservation, and the correct handling of MessageSendParams updates, including tenant preservation. The changes are well-implemented and improve the overall design and reliability of the RequestContext.
server-common/src/main/java/io/a2a/server/agentexecution/RequestContext.java
Outdated
Show resolved
Hide resolved
server-common/src/main/java/io/a2a/server/tasks/AgentEmitter.java
Outdated
Show resolved
Hide resolved
6520fc4 to
1095b42
Compare
This is possible by moving the generation of IDs when not set into the builder, and making sure the builder is used.