Stream Events (SSE)
Agent Interaction
Stream Events (SSE)
Real-time event stream using Server-Sent Events.
GET
Stream Events (SSE)
Overview
Connect to a real-time event stream to receive updates as they happen. This uses Server-Sent Events (SSE) for push-based updates instead of polling.SSE provides lower latency than polling and is more efficient for monitoring long-running tasks.
Request
The UUID of the session
Bearer token for authentication
Must be set to
text/event-streamFilter out system messages, internal prompts, and images
Comma-separated list of event types to subscribe toAvailable types:
step- Agent actions and navigationthought- Agent reasoningquestion- Questions requiring user inputdone- Task completionerror- Errorslog- Debug logspaused- Session pausedresumed- Session resumedheartbeat- Keep-alive signals
Send historical messages immediately upon connection
Response Format
SSE events follow this format:Event Fields
Message ID for tracking
Event type (thought, question, done, error, etc.)
Event payload as JSON string
Example Requests
Event Types
thought
Agent’s reasoning or actionsquestion
Agent needs user inputdone
Task completed successfullyerror
Error occurredheartbeat
Keep-alive signal (sent every ~30 seconds)Use Cases
Real-time Monitoring Dashboard
Filtered Event Stream
Auto-reconnect on Disconnect
SSE vs Polling
| Feature | SSE | Polling |
|---|---|---|
| Latency | Low (~instant) | Medium (1-3s) |
| Efficiency | High | Lower |
| Complexity | Medium | Simple |
| Use Case | Real-time monitoring | Simple status checks |
- You need immediate updates
- Monitoring long-running tasks
- Building interactive UIs
- Simple status checks
- Client doesn’t support SSE
- Stateless serverless functions
Connection Management
Best Practices
The connection will automatically close when the task completes (
done or error event).Set
include_history: false if you only want new events, not historical messages from before connection.