This is an experimental project, looking at how to live-stream AI responses back to multiple connected clients. All implementations use Cloudflare durable objects and React Server Components (RSC) with RedwoodSDK.
This is a companion repository for a blog post, deployed at https://agents-chat.jldec.me/.
- RSC Chat - Uses RedwoodSDK realtime websockets
- Agent Chat - Uses Cloudflare Agents websockets with separate durable object storage
- Agent SDK Chat - Uses Cloudflare Agents AIChatAgent with the useAgentChat hook
- TinyBase Chat - Uses TinyBase websockets
- Agent Agent Chat - Advanced Cloudflare agent with subagents and MCP tool calling
RedwoodSDK RSC:
- Server components provide succinct way to populate JSX and keep clients updated.
- This makes using react with Cloudflar workers super easy, and simplifies async data loading.
Cloudflare Agents:
- AIChatAgent provides its own websocket protocol for multi-user real-time sync
- Agents also offer raw websockets give full control over payloads for optimizations
- Vercel's AI SDK abstracts tool calling and supports different LLMs
TinyBase:
- DB sync engines can improve UX with local-first client-side persistence
- The approach requires careful validation since database operations run on the client
- Live Demo: https://agents-chat.jldec.me/
- Blog Post: https://jldec.me/blog/multi-user-ai-chat-with-redwoodsdk-rsc-and-cloudflare-agents
- RedwoodSDK Docs: https://docs.rwsdk.com/
- Cloudflare Workers Docs: https://developers.cloudflare.com/workers/
- Cloudflare Agents Docs: https://developers.cloudflare.com/agents/