Record Class TaskStatus

java.lang.Object
java.lang.Record
org.a2aproject.sdk.spec.TaskStatus
Record Components:
state - the current state of the task (required)
message - an optional message providing additional context about the status (optional)
timestamp - the time when this status was created, in UTC (defaults to current time if not provided)

public record TaskStatus(TaskState state, @Nullable Message message, OffsetDateTime timestamp) extends Record
Represents the status of a task at a specific point in time in the A2A Protocol.

TaskStatus encapsulates the current state of a task along with an optional message providing additional context and a timestamp indicating when the status was created. This information is essential for tracking task lifecycle and communicating progress to clients.

The status transitions through various states as the agent processes the task:

  • SUBMITTED: Task has been received and queued
  • WORKING: Agent is actively processing the task
  • INPUT_REQUIRED: Agent needs additional input from the user
  • AUTH_REQUIRED: Agent requires authentication or authorization
  • COMPLETED: Task finished successfully (final state)
  • CANCELED: Task was canceled by the user or system (final state)
  • FAILED: Task failed due to an error (final state)
  • REJECTED: Task was rejected by the agent (final state)
  • UNKNOWN: Task state cannot be determined (final state)

TaskStatus is immutable and automatically generates a UTC timestamp if none is provided. This class is used within Task objects and TaskStatusUpdateEvent instances to communicate state changes.

See Also:
  • Constructor Details

    • TaskStatus

      public TaskStatus(TaskState state, @Nullable Message message, @Nullable OffsetDateTime timestamp)
      Compact constructor for validation and timestamp initialization. Validates that the state is not null and sets the timestamp to current UTC time if not provided.
      Parameters:
      state - the task state
      message - optional status message
      timestamp - the status timestamp
    • TaskStatus

      public TaskStatus(TaskState state)
      Creates a TaskStatus with only a state, using the current UTC time as the timestamp.

      This is a convenience constructor for creating status updates without an accompanying message.

      Parameters:
      state - the task state (required)
  • Method Details

    • timestamp

      public OffsetDateTime timestamp()
      Returns the timestamp when this status was created.
      Returns:
      the UTC timestamp of the status
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • state

      public TaskState state()
      Returns the value of the state record component.
      Returns:
      the value of the state record component
    • message

      public @Nullable Message message()
      Returns the value of the message record component.
      Returns:
      the value of the message record component