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
- Client opens an SSE connection on
/events.
- Agent updates global expression → SSE event
agent:update is pushed to all clients.
- Client receives the event instantly without polling.
- If the connection drops, the client auto-reconnects.
Acceptance Criteria
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.
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
Example Flow
/events.agent:updateis pushed to all clients.Acceptance Criteria
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.