Backend
Resumable streams
If the connection drops mid-answer, reconnect and continue instead of regenerating.
What it is and why it exists
Generation continues server-side, writing events to a buffer (Redis stream, database) keyed by message ID; the client reconnects with the last event ID it saw and the server replays from there, then continues live.
Quick prototype
Reload = regenerate.
In production, at scale
Generation decoupled from the HTTP connection (worker or background task), events persisted with IDs, SSE Last-Event-ID support, TTL on buffers, and the final message stored once complete.
Vendors and tools
| Redis Streams | Event buffers |
|---|---|
| Vercel AI SDK resumable streams | Helpers for resumption |
On AWS: ElastiCache Redis streams; DynamoDB for message state.
How it fails
- Generation tied to one instance’s memory, lost on deploy
What the interviewer asks next
What does decoupling generation from the request buy you?
Resumption after network drops, multiple tabs watching the same answer, deploys that don’t kill in-flight answers, and a clean place to enforce cancellation.