building-ai-agent-on-cloudflare

Build stateful AI agents on Cloudflare with the Agents SDK.

2.6k|242|Updated Dec 10, 2025
One-click install
npx skills add https://github.com/cloudflare/skills --skill building-ai-agent-on-cloudflare-cloudflare
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: building-ai-agent-on-cloudflare
Source: https://github.com/cloudflare/skills/tree/main/skills/building-ai-agent-on-cloudflare
Command: npx skills add https://github.com/cloudflare/skills --skill building-ai-agent-on-cloudflare-cloudflare

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill enables rapid development and deployment of stateful AI agents on Cloudflare Workers using the Agents SDK, providing real-time chat, tool integration, and edge orchestration.

Core Features & Use Cases

  • Stateful agents with persistent per-agent state and real-time WebSocket communication.
  • Tool integration to call external services and coordinate tasks across components.
  • Edge deployment and orchestration for multi-step workflows and scheduled tasks.

Quick Start

Install Node.js 18+ and Wrangler, scaffold a new project from the starter template, and start the local dev server. Example: npm create cloudflare@latest -- my-agent --template=cloudflare/agents-starter; cd my-agent; npm install; npm start. Then connect a client to the agent's WebSocket endpoint at wss://<your-subdomain>.workers.dev/agents/MyAgent/session-id; deploy to Cloudflare when ready.

Frequently Asked Questions about building-ai-agent-on-cloudflare

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build stateful AI agents on Cloudflare Workers?

To build stateful AI agents on Cloudflare Workers, use the Agents SDK with Durable Objects for persistent per-agent state and WebSocket communication. It supports tool integration and SQL storage for multi-step workflows and scheduled tasks.

How do I connect a client to a Cloudflare edge agent via WebSocket?

Connect a client to a Cloudflare edge agent by targeting the WebSocket endpoint at wss://<your-subdomain>.workers.dev/agents/MyAgent/session-id. This enables real-time chat and tool-calling interactions directly through the Agents SDK.

What do I need to deploy edge AI agents using the Cloudflare Agents SDK?

Deploying edge AI agents requires Node.js 18+, Wrangler installed, a Cloudflare account, and the Agents SDK bindings. Optional AI bindings are needed for model calls, supporting edge deployments with per-agent routing.

Can I use Durable Objects for persistent state in Cloudflare AI agents?

Yes, you can use Durable Objects for persistent state in Cloudflare AI agents. The Agents SDK leverages Durable Objects and SQL storage to maintain per-agent state, enabling orchestrated multi-step workflows and scheduled tasks.

What is the best way to orchestrate multi-step workflows for AI agents at the edge?

The best way to orchestrate multi-step workflows for edge AI agents is using the Cloudflare Agents SDK. It provides edge orchestration across components, tool integration for external services, and supports scheduled tasks with real-time WebSocket communication.

How do I scaffold a new Cloudflare agent project from a starter template?

Scaffold a new Cloudflare agent project by running npm create cloudflare@latest -- my-agent --template=cloudflare/agents-starter. After running npm install and npm start, the local dev server launches for immediate edge deployment testing.