Skip to main content
GET
Stream Events

Stream Task Events

Connect to the unified SSE stream to receive the complete conversation history followed by live execution events. This is the recommended way to build a real-time chat UI.

Request

Path Parameters

Stream Behavior

The stream delivers events in three phases:
  1. History replay - Emits history_message events for each saved conversation message
  2. History complete - Emits history_done with { messageCount, isStreaming }
  3. Live events (if task is running) - Catch-up state followed by real-time content, thought, tool_call, tool_result, subagent_start, subagent_thought, subagent_tool, subagent_end, error, and done events
If the task is not currently running, the stream ends after history_done.

Reconnection

You can disconnect and reconnect at any time. On reconnect, the stream replays the full history and catches up to the current state. The task continues executing in the background regardless of stream connections - disconnecting does not cancel the task.

Heartbeat

The server sends :heartbeat comments every 15 seconds to keep the connection alive. These can be safely ignored by your SSE parser.

Stream Output Example

Event Types

history_message

A replayed conversation message from history.

history_done

Signals that history replay is complete.

Live Events

After history_done, if isStreaming is true, the stream delivers live events including content, thought, tool_call, tool_result, subagent events (subagent_start, subagent_thought, subagent_tool, subagent_end), error, and done. See Streaming Events for the complete event format reference.

Examples

Use Cases

Building a Chat UI

Use the stream endpoint to hydrate your chat interface and receive live updates:

Reconnecting After Disconnect

The stream endpoint is the recommended way to consume task events. It replaces the previous pattern of reading SSE from POST endpoints. Use GET /tasks/:id/history as a REST alternative when SSE is not practical.

Errors