Enum Class TaskState

java.lang.Object
java.lang.Enum<TaskState>
org.a2aproject.sdk.spec.TaskState
All Implemented Interfaces:
Serializable, Comparable<TaskState>, Constable

public enum TaskState extends Enum<TaskState>
Defines the lifecycle states of a Task in the A2A Protocol.

TaskState represents the discrete states a task can be in during its execution lifecycle. States are categorized as either transitional (non-final) or terminal (final), where terminal states indicate that the task has reached its end state and will not transition further. A subset of transitional states are also marked as interrupted, indicating the task execution has paused and requires external action before proceeding.

Active Transitional States:

  • TASK_STATE_SUBMITTED: Task has been received by the agent and is queued for processing
  • TASK_STATE_WORKING: Agent is actively processing the task and may produce incremental results

Interrupted States:

  • TASK_STATE_INPUT_REQUIRED: Agent needs additional input from the user to continue
  • TASK_STATE_AUTH_REQUIRED: Agent requires authentication or authorization before proceeding

Terminal States:

  • TASK_STATE_COMPLETED: Task finished successfully with all requested work done
  • TASK_STATE_CANCELED: Task was explicitly canceled by the user or system
  • TASK_STATE_FAILED: Task failed due to an error during execution
  • TASK_STATE_REJECTED: Task was rejected by the agent (e.g., invalid request, policy violation)
  • UNRECOGNIZED: Task state cannot be determined (error recovery state)

The isFinal() method can be used to determine if a state is terminal, which is important for event queue management and client polling logic. The isInterrupted() method identifies states where the task is paused awaiting external action.

See Also:
  • Enum Constant Details

    • TASK_STATE_SUBMITTED

      public static final TaskState TASK_STATE_SUBMITTED
      Task has been received and is queued for processing (transitional state).
    • TASK_STATE_WORKING

      public static final TaskState TASK_STATE_WORKING
      Agent is actively processing the task (transitional state).
    • TASK_STATE_INPUT_REQUIRED

      public static final TaskState TASK_STATE_INPUT_REQUIRED
      Agent requires additional input from the user to continue (interrupted state).
    • TASK_STATE_AUTH_REQUIRED

      public static final TaskState TASK_STATE_AUTH_REQUIRED
      Agent requires authentication or authorization to proceed (interrupted state).
    • TASK_STATE_COMPLETED

      public static final TaskState TASK_STATE_COMPLETED
      Task completed successfully (terminal state).
    • TASK_STATE_CANCELED

      public static final TaskState TASK_STATE_CANCELED
      Task was canceled by user or system (terminal state).
    • TASK_STATE_FAILED

      public static final TaskState TASK_STATE_FAILED
      Task failed due to an error (terminal state).
    • TASK_STATE_REJECTED

      public static final TaskState TASK_STATE_REJECTED
      Task was rejected by the agent (terminal state).
    • UNRECOGNIZED

      public static final TaskState UNRECOGNIZED
      Task state is unknown or cannot be determined (terminal state).
  • Method Details

    • values

      public static TaskState[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static TaskState valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isFinal

      public boolean isFinal()
      Determines whether this state is a terminal (final) state.

      Terminal states indicate that the task has completed its lifecycle and will not transition to any other state. This is used by the event queue system to determine when to close queues and by clients to know when to stop polling.

      Terminal states: COMPLETED, FAILED, CANCELED, REJECTED, UNRECOGNIZED.

      Returns:
      true if this is a terminal state, false else.
    • isInterrupted

      public boolean isInterrupted()
      Determines whether this state is an interrupted state.

      Interrupted states indicate that the task execution has paused and requires external action before proceeding. The task may resume after the required action is provided. Interrupted states are NOT terminal - streams should remain open to deliver state updates.

      Interrupted states: INPUT_REQUIRED, AUTH_REQUIRED.

      Per A2A Protocol Specification 4.1.3 (TaskState): "TASK_STATE_INPUT_REQUIRED: This is an interrupted state." "TASK_STATE_AUTH_REQUIRED: This is an interrupted state."

      Returns:
      true if this is an interrupted state, false else.