Streaming and Async
Streaming and Asynchronous Operations for Long-Running Tasks
Many agent operations are long-running, multi-step, or require human intervention. A2A provides mechanisms to keep clients informed—whether they stay connected or not.
Streaming with Server-Sent Events (SSE)
SSE is ideal when the client can keep an HTTP connection open and wants incremental results or real-time status updates.
Key points:
- Server capability: the AgentCard declares
capabilities.streaming: true. - Initiate streaming: clients call
message/stream. - Event types (examples):
Task(current state snapshot)TaskStatusUpdateEvent(state changes and intermediate messages)TaskArtifactUpdateEvent(artifact chunks viaappend/lastChunk)
- Termination: the server ends a cycle by emitting a final status update (commonly with
final: true) and closing the stream. - Resubscription: clients can reconnect to an active task stream using
tasks/resubscribeif the connection drops.
Push notifications (disconnected scenarios)
For tasks that take minutes, hours, or days—or when clients can’t keep a connection open—A2A supports push notifications to a client webhook.
Key points:
- Server capability: the AgentCard declares
capabilities.pushNotifications: true. - Configuration: the client provides a
PushNotificationConfig(webhook URL, optional token, optional auth details), either in the initial request or via a task method such astasks/pushNotificationConfig/set. - Client action: after receiving a notification, the client typically calls
tasks/getto fetch the full updatedTask.
Security considerations (push notifications)
Push notifications are outbound, server-initiated HTTP requests, so both sides must take care:
- Server-side: validate webhook URLs (prevent SSRF/DDoS amplification), enforce allowlists/verification, and authenticate to the webhook.
- Client-side: verify the caller (signatures/JWT/HMAC/API keys), prevent replay (timestamps/nonces), and rotate keys safely.