Skip to content

Getting started

Last updated View as MarkdownAgent setup

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

Prerequisites

  • Node.js 24+
  • A Cloudflare account with Workers AI access
  • Familiarity with TypeScript and Cloudflare Workers

1. Create a project

mkdir my-think-agent && cd my-think-agent
npm init -y

Install 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 vite

2. Configure wrangler

Create wrangler.jsonc:

{