agents-sdk

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

Updated Dec 9, 2025
One-click install
npx skills add https://github.com/Aki2022/skills --skill agents-sdk-aki2022
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: agents-sdk
Source: https://github.com/Aki2022/skills/tree/main/agents-sdk
Command: npx skills add https://github.com/Aki2022/skills --skill agents-sdk-aki2022

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill 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 up-to-date guidance for the Cloudflare Agents SDK, prioritizing retrieval from official docs over potentially outdated training knowledge. ## Core Features & Use Cases - Stateful Agents: Create Durable Object-backed agents with SQLite-persisted state, @callable RPC methods, and automatic client state sync via React hooks like useAgent. - Chat & Streaming: Build streaming chat agents with AIChatAgent, resumable streams, tool calling, and human-in-the-loop approval flows. - Background Processing: Run durable Workflows, FIFO queues with retries, cron scheduling, and fibers that survive Durable Object eviction. - Integrations: Connect to or build MCP servers, handle email routing, webhooks, push notifications, voice (STT/TTS), and browser automation. - Use Case: Build a customer support chat agent that persists conversation history, schedules follow-up reminders, calls MCP tools, and streams responses to a React frontend. ## 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.

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?

Extend the Agent class from the agents package, define typed state with 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 streaming chat to a Cloudflare agent?

Use AIChatAgent from @cloudflare/ai-chat and implement onChatMessage with streamText from the AI SDK. Pass abortSignal and onFinish for proper cleanup and message persistence; streams resume automatically on client reconnect.

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 MCP servers using the McpAgent class with the @modelcontextprotocol/sdk package.

Why does @callable break with experimentalDecorators in tsconfig?

Enabling experimentalDecorators in tsconfig conflicts with the decorators used by the Agents SDK and breaks @callable methods. Extend the agents/tsconfig configuration instead, which applies the correct compiler settings.

When should I use Workflows instead of agent queues?

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