Run Workflows inside Dynamic Workers with @cloudflare/dynamic-workflows
Key Points
- Dynamic Workflows now run durably inside Dynamic Workers loaded at runtime
- Automatic Worker reloading ensures Workflows resume with correct code after long sleeps
- Perfect for multi-tenant SaaS and AI agent frameworks with dynamic execution
Summary
Cloudflare has released the @cloudflare/dynamic-workflows library, enabling durable Workflow execution within Dynamic Workers. This solves the challenge of maintaining durability when Worker code is loaded at runtime, as the original code may no longer be in memory when a Workflow resumes after sleeping for extended periods.
Key Points
- Automatic Worker Reloading: The library tags each Workflow instance with metadata (e.g., tenant ID) and automatically reloads the matching Dynamic Worker when the Workflow awakens
- No Pre-registration Required: Dynamic Workers are created on-demand; you don't need to register Workflows upfront or manage them individually
- Transparent Execution: Workflow code behaves normally while the Workflows engine handles persistence and retries behind the scenes
- Multi-tenant Support: Ideal for SaaS platforms where each tenant defines custom automation (onboarding sequences, approval chains, billing logic)
- AI Agent Frameworks: Supports agents that generate and execute multi-step plans at runtime, surviving restarts and waiting for human approval
- Job Systems: Enables multi-tenant job processing where each customer submits logic and every step persists progress with automatic retries