agents-sdk

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill 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 — infrastructure that is complex to wire together manually. This Skill provides retrieval-first guidance and code patterns for the Cloudflare Agents SDK so agents are built against current documentation rather than outdated training knowledge. ## Core Features & Use Cases - Stateful Agents with RPC: Create Agent classes with SQLite-backed state, @callable RPC methods, and automatic client state sync via React hooks like useAgent. - Chat, Workflows & Background Processing: Build streaming chat agents with AIChatAgent, durable multi-step Workflows, built-in FIFO queues, retries with backoff, and cron/interval scheduling. - Integrations: Connect to or build MCP servers, handle email routing, webhooks, push notifications, and experimental voice, browser automation, and Codemode capabilities. - Use Case: You need a chat application where each user session is a persistent agent that streams LLM responses, survives disconnects with resumable streaming, and runs scheduled follow-up tasks — this Skill walks through the Wrangler config, agent class, and React client setup. ## Quick Start Ask the agent to scaffold a Cloudflare Workers agent with a Counter class, Wrangler Durable Object bindings, and a React client using useAgent.

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 streaming chat to a Cloudflare agent?▼

Extend AIChatAgent from @cloudflare/ai-chat and implement onChatMessage using streamText from the AI SDK. Always pass abortSignal and onFinish for proper cleanup and message persistence; resumable streaming is enabled by default.

What is the difference between Think and AIChatAgent?▼

Think handles the streamText loop, tool execution, and message persistence automatically via getModel and getSystemPrompt overrides, but requires the experimental compatibility flag. AIChatAgent gives full control inside onChatMessage where you write the streaming logic yourself.

Why does @callable break in my Cloudflare agent project?▼

The @callable decorator breaks when experimentalDecorators is enabled in tsconfig.json. Remove that flag and extend the agents/tsconfig base configuration, then regenerate types with npx wrangler types.

Can Cloudflare agents connect to MCP servers?▼

Yes, agents include a multi-server MCP client via this.addMcpServer with OAuth support, and this.mcp.getAITools exposes remote tools to the LLM. You can also build MCP servers using McpAgent with streamable HTTP, SSE, or RPC transports.

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 tasks, multi-step pipelines with automatic retries, and human-in-the-loop approval flows via waitForEvent.