Skip to main content
POST

Overview

The message/stream method enables real-time communication with A2A agents using Server-Sent Events (SSE). This allows you to receive partial responses as the agent processes your request, providing a more interactive experience.
Streaming Communication: This method uses Server-Sent Events for real-time response streaming. The connection remains open until the agent completes the response.

Request

Headers

string
required
Must be application/json
string
required
Must be text/event-stream for SSE support
string
required
Your API key for authentication
string
Recommended: no-cache for real-time streaming

Path Parameters

string
required
Unique identifier of the target agent

Body Parameters

string
required
JSON-RPC version, must be "2.0"
string
required
Unique identifier for this request (for response correlation)
string
required
Must be "message/stream"
object
required
Message parameters object (same structure as message/send)

Response

Server-Sent Events Stream

The response is delivered as a stream of Server-Sent Events. Each event contains a JSON object with the current state of the task.

Event Format

Event Data Structure

string
JSON-RPC version, always "2.0"
object
Result object containing the current task state
string
Request ID (matches the request ID)

Examples

Stream Lifecycle

State: submittedThe request has been received and queued for processing.
State: workingThe agent is actively processing the request. May include progress updates.
State: completedThe agent has finished processing and provides the final response.

Error Handling

Stream Errors

Errors during streaming are sent as regular JSON-RPC error responses:

Connection Management

  • Keep-Alive: Server maintains connection until completion
  • Heartbeat: Server may send ping events to keep connection alive
  • Timeout: Connections timeout after 5 minutes of inactivity
  • Reconnection: Clients should implement reconnection logic
  • Network Issues: Implement exponential backoff for reconnection
  • Partial Responses: Store received data before reconnecting
  • Task Continuation: Use task ID to check status after reconnection

Best Practices

  • Buffer Management: Process events as they arrive, don’t buffer unnecessarily
  • Connection Pooling: Reuse connections when possible
  • Timeout Handling: Set appropriate timeouts for long-running tasks
  • Event Parsing: Always validate JSON before parsing
  • Final Flag: Check final flag to know when stream is complete
  • Error Handling: Implement proper error handling for network issues
  • Progress Indicators: Use progress information to show user feedback
  • Partial Results: Display partial content as it arrives
  • Cancellation: Provide ability to cancel long-running streams

Comparison with message/send