agents-sdk

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires agents, @cloudflare/ai-chat, @cloudflare/think, @cloudflare/voice, @cloudflare/codemode, @modelcontextprotocol/sdk, ai, zod, web-push, postal-mime, workers-ai-provider, 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 restarts requires complex infrastructure. This Skill provides guidance for the Cloudflare Agents SDK so you can implement stateful agents, durable workflows, chat applications, and MCP servers on Cloudflare Workers without designing that infrastructure yourself. ## Core Features & Use Cases - Stateful Agents with RPC: Create Agent classes with SQLite-backed state, @callable RPC methods, and automatic state sync to React clients via useAgent. - Durable Background Work: Use Workflows, runFiber durable execution, built-in FIFO queues, and retries with exponential backoff for long-running tasks. - Chat, MCP, and Integrations: Build streaming chat agents with AIChatAgent, connect to or build MCP servers, handle email, webhooks, push notifications, and experimental voice and browser tools. - Use Case: You want a chat assistant that remembers conversation history per user, schedules follow-up reminders, and calls external MCP tools. This Skill walks you through the Wrangler config, agent class, scheduling APIs, and React hooks to ship it. ## Quick Start Ask the agent to scaffold a Cloudflare Workers agent class with persistent state, a callable RPC method, and the required wrangler.jsonc Durable Object bindings and migrations.

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, and expose methods with @callable. Configure a Durable Object binding and a new_sqlite_classes migration in wrangler.jsonc, then route requests with routeAgentRequest.

How do I add scheduling to a Cloudflare agent?

Use this.schedule with a delay in seconds, a Date, or a cron expression, or this.scheduleEvery for fixed intervals. The named handler method receives the payload and schedule object, and you can attach retry options per schedule.

What is the difference between AIChatAgent and Think in the Agents SDK?

AIChatAgent gives you full control inside onChatMessage where you write the streamText loop and wire tools yourself. Think handles the streamText loop, tool execution, and persistence automatically, but requires the experimental compatibility flag.

Can a Cloudflare agent 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 the serve method.

Why does @callable break with experimentalDecorators enabled?

Enabling experimentalDecorators in tsconfig changes decorator semantics and breaks the @callable RPC decorator used by the Agents SDK. Extend the agents/tsconfig base configuration instead, which sets the correct compiler options.

When should I use Workflows instead of the agent queue?

Use the built-in queue for short background tasks under 30 seconds with FIFO processing. Use AgentWorkflow for long-running multi-step tasks, automatic retries, and human-in-the-loop approval flows that must survive failures.