agents-sdk

Build stateful AI agents on Cloudflare Workers using the Agents SDK.

Updated May 23, 2026
One-click install
npx skills add https://github.com/kveperedo/website --skill agents-sdk-kveperedo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: agents-sdk
Source: https://github.com/kveperedo/website/tree/main/.agents/skills/agents-sdk
Command: npx skills add https://github.com/kveperedo/website --skill agents-sdk-kveperedo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires agents, @cloudflare/ai-chat, ai, @ai-sdk/react, and includes references (resource) components.

What problem does it solve? Building AI agents that maintain persistent state, handle real-time WebSocket connections, run scheduled tasks, and survive infrastructure restarts requires complex distributed systems work. This Skill provides the patterns and APIs to implement these capabilities on Cloudflare Workers without managing servers or state infrastructure manually. ## Core Features & Use Cases - Stateful Agents with RPC: Create Agent classes with SQLite-backed persistent state, @callable RPC methods, and automatic state sync to React clients via useAgent hooks. - Chat, Workflows & Background Processing: Build streaming chat agents with AIChatAgent, durable multi-step workflows, scheduled tasks, queues with retries, and durable execution that survives Durable Object eviction. - Integrations: Connect to MCP servers or build your own with McpAgent, handle email routing, webhooks, push notifications, and experimental voice and browser automation. - Use Case: Imagine building a customer support chat agent that remembers conversation history, schedules follow-up checks every hour, calls external MCP tools, and streams responses to a React frontend — all deployed as a single Cloudflare Worker. ## Quick Start Use the agents-sdk skill to create a Cloudflare Worker agent class with persistent state and a callable RPC method, then connect it to a React client with useAgent.

Frequently Asked Questions about agents-sdk

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

FAQPage Schema
How do I build a stateful AI agent on Cloudflare Workers?▼

Install the agents package, extend the Agent class with typed state and an initialState property, then expose methods with @callable. Configure a Durable Object binding and a new_sqlite_classes migration in wrangler.jsonc, and route requests with routeAgentRequest.

How do I add streaming chat to a Cloudflare agent?▼

Extend AIChatAgent from @cloudflare/ai-chat and implement onChatMessage using streamText from the AI SDK. Pass abortSignal and onFinish for proper cleanup and message persistence, then connect from React with useAgentChat.

Can Cloudflare agents connect to MCP servers?▼

Yes, agents include a multi-server MCP client via this.addMcpServer, supporting OAuth flows and Streamable HTTP, SSE, or RPC transports. You can also build your own MCP server by extending McpAgent and serving it with MyMCP.serve.

Why does @callable break with experimentalDecorators enabled?▼

Enabling experimentalDecorators in tsconfig conflicts with the decorators used by the Agents SDK and breaks @callable methods. Keep experimentalDecorators disabled and extend the agents/tsconfig for correct compiler settings.

What is the difference between Workflows and durable execution in agents?▼

Workflows via AgentWorkflow handle long-running multi-step tasks over 30 seconds with automatic retries and human approval. Durable execution with runFiber and stash suits shorter work that must survive Durable Object eviction, but requires manual recovery logic in onFiberRecovered.