Agent Skill

Cloudflare Agents SDK
Build stateful AI agents on Cloudflare Workers using the Agents SDK with durable execution, state management, and real-time capabilities
What is Cloudflare Agents SDK?
This skill teaches agents how to build sophisticated, stateful AI applications on Cloudflare's edge infrastructure using the Agents SDK. The skill covers creating Agent classes that extend the framework's base capabilities, implementing durable workflows with automatic retries and state persistence, managing conversational state across user sessions, handling real-time WebSocket connections for interactive applications, integrating with Cloudflare's AI models and other platform services, building MCP (Model Context Protocol) servers, and deploying agents with proper observability. The agent learns architectural patterns for structuring agents with clear separation between conversation logic, tool execution, and state management. The skill establishes boundaries between ephemeral Workers operations and durable agent state, guiding decisions about when to use standard Workers versus Durable Objects for persistence. Trade-offs include choosing between stateless request-response patterns versus stateful conversational flows, balancing cold start performance against state persistence requirements, and selecting appropriate retry strategies for different failure scenarios. The skill emphasizes leveraging Cloudflare's global network while understanding edge computing constraints around execution time and memory.
Key capabilities
Durable workflow orchestration
Implements long-running workflows with automatic checkpointing, retry logic, and state persistence across failures, enabling reliable multi-step agent operations
Stateful conversation management
Maintains conversation history and context across user interactions using Durable Objects, supporting multi-turn dialogues with proper state isolation between sessions
Real-time WebSocket integration
Handles bidirectional communication for interactive agent applications, streaming responses, and live updates using Cloudflare's WebSocket support
Tool and service integration
Connects agents to external APIs, Cloudflare services (AI, KV, R2, D1), and custom tools through standardized interfaces with proper error handling and observability
Use cases
Customer support chatbot with memory
Build a conversational agent that remembers previous interactions, accesses customer data from Cloudflare D1, and maintains context across multiple support sessions
Multi-step data processing workflows
Create durable workflows that fetch data from APIs, process it through multiple stages with AI models, handle retries for transient failures, and persist results to R2 storage
Real-time collaborative editing assistant
Develop an agent that provides live suggestions via WebSocket connections, maintains document state, and coordinates between multiple users editing simultaneously
Scheduled task orchestration
Implement agents triggered by Cloudflare Cron that perform complex operations—data aggregation, report generation, system health checks—with durable execution guarantees
Compatibility
- @cloudflare/agents-sdk
