Enum Class TaskState
- All Implemented Interfaces:
Serializable,Comparable<TaskState>,Constable
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionAgent requires authentication or authorization to proceed (interrupted state).Task was canceled by user or system (terminal state).Task completed successfully (terminal state).Task failed due to an error (terminal state).Agent requires additional input from the user to continue (interrupted state).Task was rejected by the agent (terminal state).Task has been received and is queued for processing (transitional state).Agent is actively processing the task (transitional state).Task state is unknown or cannot be determined (terminal state). -
Method Summary
Modifier and TypeMethodDescriptionbooleanisFinal()Determines whether this state is a terminal (final) state.booleanDetermines whether this state is an interrupted state.static TaskStateReturns the enum constant of this class with the specified name.static TaskState[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
TASK_STATE_SUBMITTED
Task has been received and is queued for processing (transitional state). -
TASK_STATE_WORKING
Agent is actively processing the task (transitional state). -
TASK_STATE_INPUT_REQUIRED
Agent requires additional input from the user to continue (interrupted state). -
TASK_STATE_AUTH_REQUIRED
Agent requires authentication or authorization to proceed (interrupted state). -
TASK_STATE_COMPLETED
Task completed successfully (terminal state). -
TASK_STATE_CANCELED
Task was canceled by user or system (terminal state). -
TASK_STATE_FAILED
Task failed due to an error (terminal state). -
TASK_STATE_REJECTED
Task was rejected by the agent (terminal state). -
UNRECOGNIZED
Task state is unknown or cannot be determined (terminal state).
-
-
Method Details
-
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
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 nameNullPointerException- 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:
trueif this is a terminal state,falseelse.
-
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:
trueif this is an interrupted state,falseelse.
-