Skip to main content
A professional-grade profile investigation agent with:
  • Server-Sent Events (SSE) for real-time streaming
  • Durability by Default - research continues if you disconnect
  • Event Replay - never miss an update by reconnecting with last_event_id
This example demonstrates how enable_event_log=True enables automatic event replay on reconnection.

The Agent

Client Implementation (Reconnection)

Here is how a frontend client handles reconnection using Last-Event-ID.

How Event Replay Works

The enable_event_log = True setting persists all emitted events to storage. When a client reconnects with last_event_id, the server replays missed events before streaming new ones.

Why This Works Well

  1. Simple API: Just await self.emit("event_type", data) (docs) - no complex output adapters
  2. Transport-Agnostic: Agent emits events, transport layer delivers them (WebSocket, SSE, etc.)
  3. True Durability: SQLiteStorage persists state, messages, and event log to disk
  4. Standard SSE: Uses standard Last-Event-ID mechanism for reconnection

Running the Example