Skip to content

Server Sent Events for Thought and Agent updates #133

@chris-cozy

Description

@chris-cozy

Summary
Introduce an SSE-based (Server-Sent Events) system to deliver real-time updates about the agent’s state and thoughts to web clients, removing the need for polling. This will provide lower latency, reduce server load, and create a smoother experience for end-users.

Details

  • Replace or augment the current polling-based update mechanism with SSE.
  • Clients establish a single persistent SSE connection to receive:
    • Agent updates: global/local expression changes, mood/state transitions.
    • Thought updates: intermediate reasoning or narrative events.
  • SSE should support reconnect logic on the client side in case of dropped connections.
  • Payloads should be lightweight JSON objects with event type and payload data.

Example Flow

  1. Client opens an SSE connection on /events.
  2. Agent updates global expression → SSE event agent:update is pushed to all clients.
  3. Client receives the event instantly without polling.
  4. If the connection drops, the client auto-reconnects.

Acceptance Criteria

  • SSE endpoint available for clients to subscribe to.
  • Agent updates are broadcast in real-time via SSE.
  • Thought updates are streamed incrementally via SSE.
  • Clients no longer require polling to stay in sync.
  • Connection handling includes retry/reconnect support.

Why This Matters
Polling adds latency, wastes server resources, and complicates client logic. SSE provides a scalable, efficient, and near-instant mechanism for updating clients about agent state and thought progression, aligning with real-time interaction needs.

Metadata

Metadata

Assignees

Labels

new featureNew feature or request

Projects

Status

Ready

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions