Build a chat agent with persistent memory, built-in file tools, and streaming — step by step.
If you are brand new to Cloudflare Agents, skim What are agents? first for the core ideas. Otherwise, you can follow along here from scratch.
By the end of this tutorial you will have a Think agent that:
- Streams responses to a React chat UI
- Has persistent memory the model can read and write
- Includes workspace file tools (read, write, edit, find, grep, delete)
- Supports custom server-side tools
- Node.js 24+
- A Cloudflare account with Workers AI access
- Familiarity with TypeScript and Cloudflare Workers
mkdir my-think-agent && cd my-think-agent
npm init -yInstall dependencies:
npm install @cloudflare/think @cloudflare/ai-chat agents ai @cloudflare/shell zod workers-ai-provider react react-dom
npm install -D wrangler @cloudflare/vite-plugin @cloudflare/workers-types @vitejs/plugin-react @tailwindcss/vite tailwindcss typescript viteCreate wrangler.jsonc:
{