How to Run Multi-Tenant Agents With Dynamic Workflows
Learn how to use Cloudflare Dynamic Workflows to execute durable, stateful operations for multi-tenant applications and long-running AI agents.
On May 1, 2026, Cloudflare released Dynamic Workflows, a TypeScript library that enables durable execution for multi-tenant applications. You can now dispatch long-running, stateful operations directly to custom code provided by your users at runtime. This removes the need for platform owners to pre-deploy or manually provision isolated containers for every user script. This guide covers how to set up the library, manage durable state, and structure your application to scale safely.
Historically, running untrusted or dynamic code required provisioning dedicated virtual machines. This imposed a substantial cold-start penalty, often taking several minutes to boot. The new @cloudflare/dynamic-workflows package changes this paradigm. It acts as a routing bridge between Cloudflare’s durable execution engine and the Dynamic Workers compute primitive.
Core Architecture and isolated Primitives
Dynamic Workflows relies on a specific set of infrastructure components to maintain execution isolation and process state across large deployments.
The primary compute layer uses Dynamic Workers. This provides an isolated, sandboxed compute environment that boots in single-digit milliseconds. When you pair this with Cloudflare’s new Git-native storage layer, you can effectively run a versioned filesystem that stores the exact code your users write, retrieving it only when the execution engine requires it.
State persistence is handled by Durable Object Facets. Every tenant receives dedicated, SQLite-backed storage for their specific application state. This ensures that persistent variables do not leak across tenant boundaries and remain highly available across execution cycles.
The routing mechanism uses the Worker Loader pattern. A single supervisor script intercepts all incoming requests. When a user calls the create() function, the supervisor evaluates the request and routes it to the correct tenant code. If a process goes to sleep and wakes up days later, the supervisor guarantees the run(event, step) payload is dispatched to the exact same isolated environment.
Installation and Requirements
You can install the 300-line MIT-licensed library using your standard package manager.
bash npm install @cloudflare/dynamic-workflows
To use the underlying compute primitives, your account must be subscribed to the Workers Paid plan. The Dynamic Workers feature is currently operating in open beta. The official repository includes an interactive browser playground equipped with live-streaming logs to help you test TenantWorkflow classes locally before deploying them to your production accounts.
Managing Workflow State
The primary advantage of this architecture is its resilience to infrastructure failures. Workflows natively survive hardware crashes, platform redeploys, and prolonged system hibernations.
You construct execution checkpoints using the step.do() method. Each step acts as an independent execution unit. If a specific network request fails due to an API timeout or an unexpected external error, the execution engine retries only that specific operation rather than restarting the entire workflow from the beginning.
For operations that require significant delays, use the step.sleep() method. This suspends the execution state for hours or days. If your process requires human-in-the-loop approvals, such as a multi-stage deployment pipeline or a manual security review, step.waitForEvent() pauses execution until a specific system trigger occurs.
These suspension methods drop the active compute context entirely. The process releases all active server connections back to the resource pool. Platforms can manage millions of unique workflows simultaneously because you only consume physical memory and CPU cycles during active step execution, resulting in a near-zero idle cost for background tasks.
Platform Scalability Limits
Cloudflare rolled out Workflows V2 alongside this library, specifically rearchitecting the control plane to handle higher throughput requirements. You must account for these concurrency limits when designing your application architecture.
| Metric | Current Limit | Previous Limit |
|---|---|---|
| Concurrent Instances | 50,000 per account | 4,500 per account |
| Instantiation Rate | 300 new instances per second | 100 new instances per second |
Common Use Cases
The combination of zero idle costs and fast boot times enables specific architectural patterns that were previously cost-prohibitive for large-scale deployments.
When building platform architectures for AI agents, systems can now generate their own multi-step execution plans as TypeScript code. Cloudflare evaluates these generated plans at runtime, allowing autonomous systems to manage multi-day research tasks or complex code refactoring loops without risk of HTTP timeouts.
For CI/CD pipeline platforms, you can spin up fresh runtime sandboxes for every sequential build step. Traditional virtual machines incur a two to three minute cold-start tax on every invocation. Dynamic Workers eliminate this wait time, radically accelerating automated deployment workflows.
If you manage a multi-tenant SaaS application, you can allow customers to upload custom business logic directly. Whether it is a custom enterprise onboarding flow or a complex billing trigger based on usage metrics, the platform runs their code safely as a first-class, durable workflow.
Review the interactive browser playground in the official Cloudflare GitHub repository to trace how the supervisor routes initial requests before migrating your existing multi-agent systems to the new execution model.
Get Insanely Good at AI
The book for developers who want to understand how AI actually works. LLMs, prompt engineering, RAG, AI agents, and production systems.
Keep Reading
Flue Integration Opens Cloudflare Agents SDK to Custom Harnesses
Cloudflare has decoupled its Agents SDK into foundational platform primitives, allowing external frameworks like Flue to orchestrate stateful AI workflows.
How to Orchestrate Parallel Subagents in Claude Code
Learn how to use dynamic workflows in Claude Code to manage up to 1,000 parallel subagents, handle resumable state, and optimize your Opus 4.8 API costs.
CodeRabbit Routes Claude 4.x Models to Fix AI Intent Gaps
CodeRabbit’s new orchestration layer uses Claude Opus 4.7 and Sonnet 4.6 to translate high-level Jira requirements into validated coding plans before execution.
Browser Run Migrates to Edge Containers for 4x Concurrency
Cloudflare rebuilt its Browser Run platform on native edge containers, quadrupling concurrency limits and halving latency for automated web tasks.
Agents Can Provision Cloudflare Accounts via Stripe Projects
Cloudflare has partnered with Stripe to launch a protocol allowing AI agents to autonomously create accounts, manage billing, and register domains.