Skip to content

feat!: Update TaskState enums#660

Merged
ehsavoie merged 1 commit intoa2aproject:mainfrom
jmesnil:TaskState
Feb 17, 2026
Merged

feat!: Update TaskState enums#660
ehsavoie merged 1 commit intoa2aproject:mainfrom
jmesnil:TaskState

Conversation

@jmesnil
Copy link
Collaborator

@jmesnil jmesnil commented Feb 16, 2026

Use the protobuf names for the TaskState enums and remove their
textual representations so that the enum names are consistent with their String name.
Rename UNKNOWN to UNRECOGNIZED to be consistent with the Protobuf definitions.

TaskState.TASK_STATE_SUBMITTED is a mouthful but we have static imports for a reason :)

This impacts the JPA serialization but I think it's worth having the same textual representation
for the task state on the wire and the DB.
Remove the TaskStateAdapter that is no longer needed for the JSON serialization.

This fixes #652.

Use the protobuf names for the TaskState enums and remove their
textual representations so that the enum names are consistent with their String name.
Rename UNKNOWN to UNRECOGNIZED to be consistent with the Protobuf definitions.

TaskState.TASK_STATE_SUBMITTED is a mouthful but we have static imports for a reason :)

This impacts the JPA serialization but I think it's worth having the same textual representation
for the task state on the wire and the DB.
Remove the TaskStateAdapter that is no longer needed for the JSON serialization.

This fixes a2aproject#652.
Signed-off-by: Jeff Mesnil <jmesnil@ibm.com>
@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 standardizes the naming and handling of TaskState enums across the codebase to ensure consistency with Protobuf definitions. It simplifies serialization mechanisms by removing custom string conversions and directly utilizing enum names, which streamlines data representation between different system components like JSON and JPA.

Highlights

  • Enum Renaming and Standardization: The TaskState enum constants have been renamed to align with Protobuf definitions, adopting a TASK_STATE_ prefix (e.g., SUBMITTED is now TASK_STATE_SUBMITTED). The UNKNOWN state was renamed to UNRECOGNIZED for consistency with Protobuf.
  • Simplified TaskState Handling: Custom string conversion methods (asString() and fromString()) and the TaskStateAdapter for JSON serialization have been removed. TaskState enums are now serialized and deserialized directly by their name, simplifying the codebase and ensuring consistent textual representation across different layers (wire, DB).
  • JPA Serialization Impact: The changes impact JPA serialization, but the author deemed it worthwhile to achieve consistent textual representation for task states on both the wire and in the database.
Changelog
  • client/base/src/main/java/io/a2a/client/ClientTaskManager.java
    • Updated TaskState.UNKNOWN to TaskState.UNRECOGNIZED in task initialization.
  • client/base/src/test/java/io/a2a/client/ClientTaskManagerTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • client/transport/jsonrpc/src/test/java/io/a2a/client/transport/jsonrpc/JSONRPCTransportStreamingTest.java
    • Updated TaskState.COMPLETED to TaskState.TASK_STATE_COMPLETED in test assertions.
  • client/transport/jsonrpc/src/test/java/io/a2a/client/transport/jsonrpc/JSONRPCTransportTest.java
    • Updated TaskState references in test assertions to use the new TASK_STATE_ prefixed names.
  • client/transport/jsonrpc/src/test/java/io/a2a/client/transport/jsonrpc/sse/SSEEventListenerTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • client/transport/rest/src/main/java/io/a2a/client/transport/rest/RestTransport.java
    • Modified status parameter handling to directly use request.status() instead of request.status().asString().
  • client/transport/rest/src/test/java/io/a2a/client/transport/rest/RestTransportTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • client/transport/rest/src/test/java/io/a2a/client/transport/rest/sse/SSEEventListenerTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • client/transport/spi/src/test/java/io/a2a/client/transport/spi/sse/SSEEventListenerTest.java
    • Removed unused imports for Stream, Arguments, and MethodSource.
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • extras/opentelemetry/integration-tests/src/test/java/io/a2a/extras/opentelemetry/it/OpenTelemetryA2ABaseTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • extras/opentelemetry/server/src/test/java/io/a2a/extras/opentelemetry/OpenTelemetryRequestHandlerDecoratorTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • extras/push-notification-config-store-database-jpa/src/test/java/io/a2a/extras/pushnotificationconfigstore/database/jpa/JpaDatabasePushNotificationConfigStoreIntegrationTest.java
    • Updated TaskState.SUBMITTED to TaskState.TASK_STATE_SUBMITTED in test task creation.
  • extras/push-notification-config-store-database-jpa/src/test/java/io/a2a/extras/pushnotificationconfigstore/database/jpa/JpaPushNotificationConfigStoreTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
    • Changed task.status().state().asString() to task.status().state().name() for string representation.
  • extras/queue-manager-replicated/core/src/test/java/io/a2a/extras/queuemanager/replicated/core/EventSerializationTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • extras/queue-manager-replicated/core/src/test/java/io/a2a/extras/queuemanager/replicated/core/ReplicatedQueueManagerTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • extras/queue-manager-replicated/replication-mp-reactive/src/test/java/io/a2a/extras/queuemanager/replicated/mp_reactive/ReactiveMessagingReplicationStrategyTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • extras/queue-manager-replicated/tests-multi-instance/tests/src/test/java/io/a2a/extras/queuemanager/replicated/tests/multiinstance/MultiInstanceReplicationTest.java
    • Updated TaskState references in test assertions to use the new TASK_STATE_ prefixed names.
  • extras/queue-manager-replicated/tests-single-instance/src/test/java/io/a2a/extras/queuemanager/replicated/tests/KafkaReplicationIntegrationTest.java
    • Updated TaskState references in test assertions to use the new TASK_STATE_ prefixed names.
  • extras/task-store-database-jpa/src/main/java/io/a2a/extras/taskstore/database/jpa/JpaDatabaseTaskStore.java
    • Changed params.status().asString() to params.status().name() for setting query parameters.
  • extras/task-store-database-jpa/src/main/java/io/a2a/extras/taskstore/database/jpa/JpaTask.java
    • Simplified updateDenormalizedFields to directly use taskState.name() and removed null checks for task status.
    • Simplified updateFinalizedTimestamp by removing null checks for task status.
  • extras/task-store-database-jpa/src/test/java/io/a2a/extras/taskstore/database/jpa/JpaDatabaseTaskStoreIntegrationTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • extras/task-store-database-jpa/src/test/java/io/a2a/extras/taskstore/database/jpa/JpaDatabaseTaskStoreTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • jsonrpc-common/src/main/java/io/a2a/jsonrpc/common/json/JsonUtil.java
    • Removed the custom TaskStateTypeAdapter and its registration, allowing TaskState enums to be serialized by their default name.
  • jsonrpc-common/src/main/java/io/a2a/jsonrpc/common/wrappers/CancelTaskRequest.java
    • Updated Javadoc reference for TaskState.CANCELED to TaskState.TASK_STATE_CANCELED.
  • jsonrpc-common/src/main/java/io/a2a/jsonrpc/common/wrappers/CancelTaskResponse.java
    • Updated Javadoc reference for TaskState.CANCELED to TaskState.TASK_STATE_CANCELED.
  • jsonrpc-common/src/test/java/io/a2a/jsonrpc/common/json/StreamingEventKindSerializationTest.java
    • Updated TaskState references in test cases and JSON string assertions to use the new TASK_STATE_ prefixed names.
  • jsonrpc-common/src/test/java/io/a2a/jsonrpc/common/json/TaskSerializationTest.java
    • Updated TaskState references in test cases and JSON string assertions to use the new TASK_STATE_ prefixed names.
    • Changed state.asString() to state in a test loop for TaskState serialization.
  • reference/jsonrpc/src/test/java/io/a2a/server/apps/quarkus/A2AServerRoutesTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • server-common/src/main/java/io/a2a/server/events/EventConsumer.java
    • Updated TaskState.INPUT_REQUIRED to TaskState.TASK_STATE_INPUT_REQUIRED in isStreamTerminatingTask.
  • server-common/src/main/java/io/a2a/server/requesthandlers/DefaultRequestHandler.java
    • Removed unused imports for ArrayList and Collections.
    • Changed task.status().state().asString() to task.status().state() for error messages.
    • Updated TaskState.CANCELED to TaskState.TASK_STATE_CANCELED in cancellation logic.
  • server-common/src/main/java/io/a2a/server/tasks/AgentEmitter.java
    • Updated all TaskState references in status update methods (e.g., complete, fail, submit) to use the new TASK_STATE_ prefixed names.
  • server-common/src/main/java/io/a2a/server/tasks/ResultAggregator.java
    • Updated TaskState.AUTH_REQUIRED to TaskState.TASK_STATE_AUTH_REQUIRED in interrupt evaluation.
  • server-common/src/main/java/io/a2a/server/tasks/TaskManager.java
    • Updated static imports for FAILED and SUBMITTED to TASK_STATE_FAILED and TASK_STATE_SUBMITTED.
    • Updated TaskState references in task creation and event processing to use the new TASK_STATE_ prefixed names.
  • server-common/src/test/java/io/a2a/server/agentexecution/RequestContextTest.java
    • Updated TaskState.COMPLETED to TaskState.TASK_STATE_COMPLETED in test task creation.
  • server-common/src/test/java/io/a2a/server/events/EventConsumerTest.java
    • Updated TaskState references in test cases and JSON string assertions to use the new TASK_STATE_ prefixed names.
  • server-common/src/test/java/io/a2a/server/events/EventQueueTest.java
    • Updated TaskState references in test cases and JSON string assertions to use the new TASK_STATE_ prefixed names.
  • server-common/src/test/java/io/a2a/server/requesthandlers/AbstractA2ARequestHandlerTest.java
    • Updated TaskState.SUBMITTED to TaskState.TASK_STATE_SUBMITTED in minimal task definition.
  • server-common/src/test/java/io/a2a/server/tasks/AgentEmitterTest.java
    • Updated TaskState references in test methods to use the new TASK_STATE_ prefixed names.
  • server-common/src/test/java/io/a2a/server/tasks/InMemoryPushNotificationConfigStoreTest.java
    • Changed task.status().state().asString() to task.status().state().name() for string representation.
    • Updated TaskState.COMPLETED to TaskState.TASK_STATE_COMPLETED in test task creation.
  • server-common/src/test/java/io/a2a/server/tasks/PushNotificationSenderTest.java
    • Removed unused Part import.
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • server-common/src/test/java/io/a2a/server/tasks/ResultAggregatorTest.java
    • Removed unused atLeast import.
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • server-common/src/test/java/io/a2a/server/tasks/TaskManagerTest.java
    • Updated static imports for FAILED and SUBMITTED to TASK_STATE_FAILED and TASK_STATE_SUBMITTED.
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • spec-grpc/src/main/java/io/a2a/grpc/mapper/A2ACommonFieldMapper.java
    • Changed TaskState.UNKNOWN to TaskState.UNRECOGNIZED in valid state filtering.
  • spec-grpc/src/main/java/io/a2a/grpc/mapper/TaskStateMapper.java
    • Updated TaskState mapping logic to use the new TASK_STATE_ prefixed names and UNRECOGNIZED for both domain to proto and proto to domain conversions.
  • spec-grpc/src/test/java/io/a2a/grpc/mapper/StreamResponseMapperTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • spec-grpc/src/test/java/io/a2a/grpc/utils/ToProtoTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • spec/src/main/java/io/a2a/spec/TaskNotCancelableError.java
    • Updated Javadoc references to TaskState to use the new TASK_STATE_ prefixed names.
  • spec/src/main/java/io/a2a/spec/TaskState.java
    • Renamed enum constants (e.g., SUBMITTED to TASK_STATE_SUBMITTED, UNKNOWN to UNRECOGNIZED).
    • Removed the state field, asString() method, and fromString() method.
    • Updated the constructor to only take the isFinal boolean.
  • spec/src/main/java/io/a2a/spec/TaskStatusUpdateEvent.java
    • Updated static imports and the isFinalOrInterrupted method to use the new TASK_STATE_ prefixed names.
  • tck/src/main/java/io/a2a/tck/server/AgentExecutorProducer.java
    • Removed unused TaskStatusUpdateEvent import.
    • Updated TaskState references in task creation and cancellation logic to use the new TASK_STATE_ prefixed names.
  • tests/server-common/src/test/java/io/a2a/server/apps/common/AbstractA2AServerTest.java
    • Updated TaskState references in test task definitions and assertions to use the new TASK_STATE_ prefixed names.
  • transport/grpc/src/test/java/io/a2a/transport/grpc/handler/GrpcHandlerTest.java
    • Removed unused imports for CURRENT_PROTOCOL_VERSION and AgentEmitter.
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • transport/jsonrpc/src/test/java/io/a2a/transport/jsonrpc/handler/JSONRPCHandlerTest.java
    • Updated TaskState references in test cases to use the new TASK_STATE_ prefixed names.
  • transport/rest/src/main/java/io/a2a/transport/rest/handler/RestHandler.java
    • Simplified listTasks method to directly use TaskState.valueOf(status) and TaskState::name for valid states, removing custom string parsing logic.
  • transport/rest/src/test/java/io/a2a/transport/rest/handler/RestHandlerTest.java
    • Updated listTasks call in test to use TASK_STATE_SUBMITTED string for status filtering.
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.

@jmesnil
Copy link
Collaborator Author

jmesnil commented Feb 16, 2026

/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 introduces a significant and well-executed refactoring to align the TaskState enums with Protobuf naming conventions. The changes, including renaming enums to TASK_STATE_*, removing the custom TaskStateAdapter, and updating JPA serialization, have been applied consistently across the entire codebase. This improves consistency between the code, on-wire format, and database representation. The code is cleaner and more maintainable as a result. The breaking change is intentional and clearly communicated. Overall, this is an excellent improvement.

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 successfully updates the TaskState enums to align with the Protobuf naming conventions. This is a significant and breaking change, as noted in the title, but it has been executed thoroughly and consistently across the entire codebase. The refactoring simplifies the TaskState enum by removing the custom string representation and TaskStateTypeAdapter, leading to a more unified representation of task states across the database, JSON, and gRPC layers. All tests have been updated to reflect these changes, ensuring the new enum names and serialization behavior are correctly handled. The code simplifications in JpaTask.java and RestHandler.java are also welcome improvements. Overall, this is a well-executed refactoring that improves consistency.

@ehsavoie ehsavoie merged commit b0e1255 into a2aproject:main Feb 17, 2026
13 of 14 checks passed
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.

[Feat]: Update TaskState enum?

2 participants