Skip to content

fix: clear status.message after adding to history in TaskManager.updateWithMessage #424#425

Merged
kabir merged 2 commits intoa2aproject:mainfrom
flex-myeonghyeon:issue-424
Nov 3, 2025
Merged

fix: clear status.message after adding to history in TaskManager.updateWithMessage #424#425
kabir merged 2 commits intoa2aproject:mainfrom
flex-myeonghyeon:issue-424

Conversation

@flex-myeonghyeon
Copy link
Contributor

@flex-myeonghyeon flex-myeonghyeon commented Oct 31, 2025

Description

Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Follow the CONTRIBUTING Guide.
  • Make your Pull Request title in the https://www.conventionalcommits.org/ specification.
    • Important Prefixes for release-please:
      • fix: which represents bug fixes, and correlates to a SemVer patch.
      • feat: represents a new feature, and correlates to a SemVer minor.
      • feat!:, or fix!:, refactor!:, etc., which represent a breaking change (indicated by the !) and will result in a SemVer major.
  • Ensure the tests pass
  • Appropriate READMEs were updated (if necessary)

Fixes #424 🦕

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @flex-myeonghyeon, 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 resolves an issue where a task's status message was not being properly cleared after being moved into the task's history. The change ensures that the status.message field is explicitly set to null once its content is recorded in the history, thereby maintaining data consistency and preventing stale or duplicated information in the task's current state. A new test case has been introduced to verify this corrected behavior.

Highlights

  • Bug Fix: Clear status.message: The updateWithMessage method in TaskManager now correctly clears the status.message field after its content has been added to the task's history. This prevents the message from being redundantly stored in the current status after it has been processed and moved to the historical record.
  • New Test Case: A new comprehensive test, testUpdateWithMessage, has been added to TaskManagerTest to validate the behavior of clearing the status.message and ensuring that all messages are correctly appended to the task's history.
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 fixes a bug in TaskManager.updateWithMessage where the message from the task's status was not being cleared after being moved to the history. The change correctly creates a new TaskStatus with a null message and updates the task. A new test case is also added to verify this behavior.

My review includes a couple of suggestions for improvement:

  • In TaskManager.java, I've pointed out a redundant null check that can be simplified.
  • In TaskManagerTest.java, I've suggested a way to simplify the new test case to make it more readable and less confusing.

Overall, the fix is correct and the changes look good.

@@ -105,11 +105,15 @@ public Event process(Event event) throws A2AServerException {

public Task updateWithMessage(Message message, Task task) {
List<Message> history = task.getHistory() == null ? new ArrayList<>() : new ArrayList<>(task.getHistory());
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 null check for task.getHistory() is redundant. The Task constructor ensures that getHistory() will always return a non-null List (it defaults to an empty immutable list if history is null during construction). You can simplify this line.

Suggested change
List<Message> history = task.getHistory() == null ? new ArrayList<>() : new ArrayList<>(task.getHistory());
List<Message> history = new ArrayList<>(task.getHistory());

Comment on lines 727 to 729
TaskManager taskManagerWithUpdateMessage = new TaskManager(saved.getId(), saved.getContextId(), taskStore, updateMessage);
Task retrieved = taskManagerWithUpdateMessage.getTask();
Task updated = taskManagerWithUpdateMessage.updateWithMessage(updateMessage, retrieved);
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 test logic can be simplified here. Creating a new TaskManager instance is unnecessary and makes the test harder to follow. The initialMessage passed to the new TaskManager is also misleading as it's not used. You can reuse the existing taskManagerWithInitialMessage and the saved task object to call updateWithMessage.

Suggested change
TaskManager taskManagerWithUpdateMessage = new TaskManager(saved.getId(), saved.getContextId(), taskStore, updateMessage);
Task retrieved = taskManagerWithUpdateMessage.getTask();
Task updated = taskManagerWithUpdateMessage.updateWithMessage(updateMessage, retrieved);
Task updated = taskManagerWithInitialMessage.updateWithMessage(updateMessage, saved);

Copy link
Collaborator

@ehsavoie ehsavoie left a comment

Choose a reason for hiding this comment

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

Please apply the small changes from gemini, otherwise looks good to me

@flex-myeonghyeon
Copy link
Contributor Author

@ehsavoie
I’ve updated the comment.
Thank you.

@kabir kabir merged commit c0f34ee into a2aproject:main Nov 3, 2025
10 checks passed
kabir pushed a commit to kabir/a2a-java that referenced this pull request Nov 3, 2025
kabir pushed a commit to kabir/a2a-java that referenced this pull request Nov 3, 2025
kabir pushed a commit to kabir/a2a-java that referenced this pull request Dec 23, 2025
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.

[Bug]: TaskManager.updateWithMessage does not clear status.message after history update

4 participants