Prerequisites
- An existing agent (see Create an agent)
- An access token or client credentials
- Understanding of the task lifecycle and A2A protocol
When to stream
Use streaming when you need real-time updates as the agent processes a message:- Showing incremental progress to users
- Displaying partial results as they arrive
- Monitoring long-running tasks
Stream a new message
Usemessage:stream to send a message and receive the response as an SSE stream:
The
-N flag disables cURL’s output buffering, which is necessary for receiving SSE events in real time.SSE event format
Each event follows the W3C SSE wire format. The server currently sends onlyid and data lines. The event and retry fields are declared for forward compatibility but are not sent:
Event types
Each SSE event carries anA2AStreamResponse with exactly one field:
Subscribe to an existing task
If you have a task ID (from a non-blockingmessage:send or after a stream dropped), use tasks:subscribe to stream updates:
Resumption with Last-Event-ID
If an SSE stream drops, the intended resumption mechanism is to send theLast-Event-ID header with the most recent event ID you received:
message:stream and tasks:subscribe.
Cancel a task
Cancel an in-flight task:TASK_STATE_CANCELED.
JSON-RPC streaming binding
You can also stream via the JSON-RPC binding by sending amessage/stream method to the base A2A endpoint:
A2AStreamResponse objects.
Next steps
- Read about the task lifecycle for state transitions
- Learn how to send a message without streaming
- Understand the A2A protocol bindings