Description: Build and deploy AI Agents on Cloudflare
View cloudflare/agents on GitHub ↗
The Cloudflare Agents repository provides a comprehensive SDK for building and deploying AI agents on the Cloudflare platform. Its primary purpose is to empower developers to create persistent, stateful, and scalable agentic workloads, leveraging the power of Cloudflare's Durable Objects. These agents are designed to be highly efficient, hibernating when idle and waking on demand, allowing for the deployment of millions of agents without incurring significant costs when inactive.
The core functionality of the repository revolves around the `agents` package, which provides the foundational components for building agents. Key features include persistent state management, allowing agents to retain their data across restarts and sync state changes to connected clients in real-time. This is achieved through the use of Durable Objects, Cloudflare's object storage service. The SDK also offers callable methods, enabling developers to define methods that can be invoked remotely, ensuring type safety through the `@callable()` decorator.
Beyond the core functionality, the SDK offers a rich set of features to facilitate the development of sophisticated agentic applications. Scheduling capabilities allow for the execution of one-time, recurring, and cron-based tasks. Real-time bidirectional communication is supported through WebSockets, providing lifecycle hooks for managing agent behavior. For AI-powered applications, the SDK includes features for AI chat, such as message persistence, resumable streaming, and server/client tool execution. It also supports MCP (Multiplayer Control Protocol) functionality, allowing agents to act as MCP servers or clients. Furthermore, the SDK provides workflow capabilities, enabling the creation of durable multi-step tasks with human-in-the-loop approval. Other notable features include email integration via Cloudflare Email Routing, code mode for LLM-driven code generation, direct SQLite queries, and React hooks for seamless frontend integration. A vanilla JS client is also available for non-React environments.
The repository is structured to provide a modular and extensible development experience. The `packages` directory contains various packages, including the core `agents` SDK, a higher-level AI chat layer (`@cloudflare/ai-chat`), Hono middleware for integration with Hono apps (`hono-agents`), and an experimental code mode package (`@cloudflare/codemode`) that allows LLMs to generate executable code. The `examples` directory offers self-contained demos showcasing various SDK features, including MCP servers/clients, workflows, email agents, and more. The `openai-sdk` directory provides examples using the OpenAI Agents SDK. Comprehensive documentation is available, including full documentation on developers.cloudflare.com, markdown docs within the repository, and guides on specific patterns and workflows.
The repository is actively maintained and developed, with ongoing efforts to expand its capabilities. Future features include real-time voice agents, web browsing capabilities, sandboxed code execution, and multi-channel communication. The repository's structure, including its use of npm workspaces, facilitates efficient development and testing. While external pull requests are not currently accepted, the project encourages bug reports, feature requests, and discussions to gather feedback and guide future development. The project is licensed under the MIT license.
Fetching additional details & charts...