agents-sdk

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

Updated Nov 23, 2024
One-click install
npx skills add https://github.com/tokisakiyuu/dotfiles --skill agents-sdk-tokisakiyuu
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: agents-sdk
Source: https://github.com/tokisakiyuu/dotfiles/tree/main/home/dot_claude/skills/agents-sdk
Command: npx skills add https://github.com/tokisakiyuu/dotfiles --skill agents-sdk-tokisakiyuu

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill 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: Create Agent classes with SQLite-backed state, @callable RPC methods, scheduling, queues, retries, and durable execution via runFiber. - Chat & Streaming: Build streaming chat agents with AIChatAgent, resumable streams, tool calling, human-in-the-loop approvals, and React hooks (useAgent, useAgentChat). - Integrations: Connect to or build MCP servers, handle email routing, webhooks, push notifications, Workflows for long-running tasks, plus experimental voice, browser automation, and Think agents. - 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 — all deployed as a Cloudflare Worker with Durable Objects. ## Quick Start Ask the AI to create a Cloudflare Workers agent using the Agents SDK with a Counter class that has callable increment and decrement methods.

Frequently Asked Questions about agents-sdk

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

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

Install the agents package, extend the Agent class with typed state, and route requests with routeAgentRequest. Configure a Durable Objects binding and a new_sqlite_classes migration in wrangler.jsonc, then deploy with Wrangler.

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. On the client, use useAgent and useAgentChat React hooks; resumable streaming and message persistence are enabled by default.

What is the difference between AIChatAgent and Think?▼

AIChatAgent requires you to write the streamText loop and wire tool execution yourself, giving full control. Think is a higher-level experimental class that handles the loop, tools, and persistence automatically, requiring only getModel and getSystemPrompt overrides.

Does the Agents SDK support MCP servers?▼

Yes. Agents can connect to external MCP servers via addMcpServer with OAuth support, and you can build MCP servers using McpAgent served over Streamable HTTP, SSE, or RPC transports.

Why does @callable break with experimentalDecorators enabled?▼

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

When should I use Workflows instead of agent queues?▼

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