Package org.a2aproject.sdk.spec
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 Summary
ConstructorsConstructorDescriptionTaskStatus(TaskState state) Creates a TaskStatus with only a state, using the current UTC time as the timestamp.TaskStatus(TaskState state, @Nullable Message message, @Nullable OffsetDateTime timestamp) Compact constructor for validation and timestamp initialization. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@Nullable Messagemessage()Returns the value of themessagerecord component.state()Returns the value of thestaterecord component.Returns the timestamp when this status was created.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
TaskStatus
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 statemessage- optional status messagetimestamp- the status timestamp
-
TaskStatus
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
Returns the timestamp when this status was created.- Returns:
- the UTC timestamp of the status
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
state
Returns the value of thestaterecord component.- Returns:
- the value of the
staterecord component
-
message
Returns the value of themessagerecord component.- Returns:
- the value of the
messagerecord component
-