FluxyChat

Guides

Stream resumption

KV snapshot of an agent run after refresh. Not Think-style fiber resume after Durable Object eviction.

GET /ai/streams/active and GET /ai/streams/:id/resume read a KV snapshot (RATE_LIMIT_KV or STREAM_RESUME_KV). POST /ai/streams/:id/chunk appends text. If those bindings are missing, active lists are empty and resume returns 503.

This is not Cloudflare Think chatRecovery. If the room Durable Object hibernates mid-generation, the in-flight LLM call does not come back. Chat already written to D1 still loads on reconnect.

const streams = await client.getActiveStreams(roomId);
const hit = streams.find((s) => s.active !== false) ?? streams[0];
if (hit?.streamId) {
  const snapshot = await client.resumeStream(hit.streamId);
  // snapshot.content is what KV stored. Live token paint still uses the room WebSocket.
}

getActiveStreams / resumeStream are aliases of listActiveAiStreams / resumeAiStream. FluxyRoomChatTransport.reconnectToStream calls the same HTTP.

Room useChat from @fluxy-chat/react does not auto-call these endpoints.