Task Operations
Manage A2A task lifecycle with get, cancel, and resubscribe operations
Overview
Task operations allow you to manage the lifecycle of A2A tasks. You can check task status, cancel running tasks, and resubscribe to task updates for better control over long-running operations.
Task Management: These operations work with task IDs returned from message/send
and message/stream
methods. Tasks represent individual agent operations that can be tracked and controlled.
Common Request Structure
All task operations follow the same basic JSON-RPC 2.0 structure with different methods and parameters.
Headers
Must be application/json
Your API key for authentication
Path Parameters
Unique identifier of the target agent
tasks/get
Get the current status and result of a specific task.
Request Parameters
JSON-RPC version, must be "2.0"
Unique identifier for this request
Must be "tasks/get"
Task query parameters
Response
JSON-RPC version, always "2.0"
Task information
Example
tasks/cancel
Cancel a running or queued task.
Request Parameters
JSON-RPC version, must be "2.0"
Unique identifier for this request
Must be "tasks/cancel"
Cancellation parameters
Response
JSON-RPC version, always "2.0"
Cancellation result
Example
tasks/resubscribe
Resubscribe to task updates, useful for reconnecting to streaming tasks or getting updates after connection loss.
Request Parameters
JSON-RPC version, must be "2.0"
Unique identifier for this request
Must be "tasks/resubscribe"
Resubscription parameters
Response
For streaming tasks, this method returns a Server-Sent Events stream similar to message/stream
. For completed tasks, it returns the final status.
JSON-RPC version, always "2.0"
Resubscription result
Example
Task States and Transitions
Error Handling
Common Error Codes
Code | Description | Resolution |
---|---|---|
-32000 | Task not found | Verify task ID exists |
-32001 | Task already completed | Cannot modify completed tasks |
-32002 | Task already canceled | Cannot modify canceled tasks |
-32003 | Cancellation failed | Task may have completed during cancellation |
-32004 | Subscription failed | Task may not support streaming |
Error Response Example
Best Practices
Task Lifecycle Example
This diagram shows the possible state transitions for A2A tasks, helping you understand when different operations are valid.