CancelTask
This method initiates task cancellation based on the task’s current state:
- If the task has not been sent to an agent, it cancels immediately and transitions the task
to a terminal state (
STATUS_DONE_NOT_OKwithERROR_CODE_CANCELLED). - If the task has already been sent to an agent, the cancellation request is routed to the agent.
The agent is then responsible for deciding whether cancellation is possible or not:
- If the task can be cancelled, the agent must use
UpdateStatusand set the task status toSTATUS_DONE_NOT_OK. - If the task cannot be cancelled, the agent must use
UpdateStatusto attach aTaskErrorto the task with the error codeERROR_CODE_REJECTEDand amessageexplaining why the task cannot be cancelled.
- If the task can be cancelled, the agent must use
CancelTaskRequest
Request
task_id
The ID of the Task being cancelled.
delivery_constraints
Optional delivery constraints for only this cancel request, superseding the delivery constraints on the original task. Each field set here supersedes that task's; fields left unset keep the task's value. A running task's deliver_before is usually long past by the time it is cancelled, so inheriting it would leave nothing to bound delivery of the cancel itself.
CancelTaskResponse
Response
task
The updated task, regardless of whether the cancellation request was confirmed or denied by the agent.