Class CancelTaskRequest

All Implemented Interfaces:
A2AMessage

public final class CancelTaskRequest extends NonStreamingJSONRPCRequest<CancelTaskParams>
JSON-RPC request to cancel an in-progress task.

This request instructs the agent to cancel execution of a specific task identified by ID. The agent should stop processing, clean up resources, and transition the task to TaskState.TASK_STATE_CANCELED state if cancellation is possible.

Not all tasks can be canceled (e.g., already completed tasks), which may result in a TaskNotCancelableError.

This class implements the JSON-RPC tasks/cancel method as specified in the A2A Protocol.

See Also:
  • Constructor Details

    • CancelTaskRequest

      public CancelTaskRequest(String jsonrpc, Object id, CancelTaskParams params)
      Creates a new CancelTaskRequest with the specified JSON-RPC parameters.
      Parameters:
      jsonrpc - the JSON-RPC version (defaults to "2.0" if null)
      id - the request identifier (string, integer, or null)
      params - the request parameters containing the task ID
      Throws:
      IllegalArgumentException - if jsonrpc version is invalid, method is not "CancelTask", params is null, or id is not a String/Integer/null
    • CancelTaskRequest

      public CancelTaskRequest(Object id, CancelTaskParams params)
      Creates a new CancelTaskRequest with default JSON-RPC version and method.
      Parameters:
      id - the request identifier (string, integer, or null)
      params - the request parameters containing the task ID
      Throws:
      IllegalArgumentException - if params is null or id is not a string/integer/null
  • Method Details