agents-sdk

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

1|Updated Jul 16, 2026
One-click install
npx skills add https://github.com/sota411/codex-config --skill agents-sdk-sota411
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: agents-sdk
Source: https://github.com/sota411/codex-config/tree/main/archived-user-skills/2026-08-20/unused/agents-sdk
Command: npx skills add https://github.com/sota411/codex-config --skill agents-sdk-sota411

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 stateful, real-time AI agents requires managing WebSocket connections, persistent state, scheduling, and durable execution, which is complex to implement from scratch. This Skill provides guidance for the Cloudflare Agents SDK, prioritizing retrieval from official Cloudflare docs over potentially outdated pre-trained knowledge. ## Core Features & Use Cases - Stateful Agents: Create Agent classes with SQLite-backed persistent 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, scheduled tasks (cron, intervals, delays), FIFO queues, and retries with exponential backoff. - Integrations: Connect to or build MCP servers, handle email routing, webhooks, push notifications, and experimental voice and browser automation. - Use Case: Build a chat application where each user session is a Durable Object instance with persisted message history, scheduled reminder tasks, and MCP tool access, all deployed on Cloudflare Workers. ## Quick Start Ask the agent to create a Cloudflare Workers agent class with persistent state and a callable RPC method using the Agents SDK.

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 configure a Durable Object binding and a new_sqlite_classes migration in wrangler.jsonc. Route requests with routeAgentRequest and expose methods to clients using the @callable decorator.

How do I add scheduling to a Cloudflare agent?▼

Use this.schedule() for one-time delayed, date-based, or cron tasks, and this.scheduleEvery() for fixed intervals. The handler method receives the payload and schedule object; cron schedules auto-reschedule while one-time schedules are deleted after running.

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

AIChatAgent requires you to write the streamText loop and wire tool execution yourself inside onChatMessage, giving full control. Think handles the LLM loop, tool execution, and persistence automatically via getModel() and getSystemPrompt(), but requires the experimental compatibility flag.

Can I connect a Cloudflare agent to MCP servers?▼

Yes, agents include a multi-server MCP client. Call this.addMcpServer() with the server URL, then use this.mcp.getAITools() to merge MCP tools into your chat agent. You can also build MCP servers using the McpAgent class with streamable HTTP transport.

Why does @callable break with experimentalDecorators enabled?▼

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

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 AgentWorkflow for long-running multi-step tasks, automatic retries, and human-in-the-loop approval flows that must survive failures.