agents-sdk

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

Updated Oct 15, 2019
One-click install
npx skills add https://github.com/kkkaoru/dotfiles --skill agents-sdk-kkkaoru
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: agents-sdk
Source: https://github.com/kkkaoru/dotfiles/tree/main/.agents/skills-stroage/agents-sdk
Command: npx skills add https://github.com/kkkaoru/dotfiles --skill agents-sdk-kkkaoru

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires agents, @cloudflare/ai-chat, @cloudflare/think, @cloudflare/voice, @cloudflare/codemode, @modelcontextprotocol/sdk, web-push, and includes references (resource) components.

What problem does it solve? Building AI agents that persist 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 live documentation retrieval over potentially outdated pre-trained knowledge. ## Core Features & Use Cases - Stateful Agents & RPC: Create Agent classes with SQLite-backed state, @callable RPC methods, and automatic client synchronization via React hooks like useAgent. - Durable Background Work: Use Workflows, runFiber durable execution, built-in FIFO queues, and retries with exponential backoff for long-running tasks. - Chat, MCP & Integrations: Build streaming chat agents with AIChatAgent, connect to or build MCP servers with McpAgent, and handle email, webhooks, push notifications, voice, and browser automation. - Use Case: You need a chat application where each user session is a persistent agent that remembers conversation history, schedules follow-up reminders, and calls external MCP tools — all deployed on Cloudflare Workers. ## Quick Start Ask the AI to create a Cloudflare Workers agent using the Agents SDK with a Counter class that has persistent state and a callable increment method.

Frequently Asked Questions about agents-sdk

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

FAQPage Schema
How do I create a stateful agent on Cloudflare Workers?

Extend the Agent class from the agents package, define an initialState, and use this.setState to persist updates to SQLite. Register the class as a Durable Object binding in wrangler.jsonc with a new_sqlite_classes migration entry.

How do I build a streaming chat agent with the Agents SDK?

Extend AIChatAgent from @cloudflare/ai-chat and implement onChatMessage using streamText from the AI SDK. Always pass abortSignal and onFinish to enable proper cleanup, message persistence, and resumable streaming on 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 by extending McpAgent and registering tools and resources.

Why does @callable break with experimentalDecorators in tsconfig?

Enabling experimentalDecorators in tsconfig conflicts with the SDK's decorator implementation and breaks @callable RPC methods. Extend the agents/tsconfig base configuration instead, which applies the correct compiler settings.

When should I use Workflows instead of the agent queue?

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

Does agent state survive Durable Object eviction?

State persists to SQLite automatically, but in-flight work does not. Use runFiber with ctx.stash checkpoints and implement onFiberRecovered to resume work after eviction, since only the stash data is restored, not the lambda.