Briefing

Dynamic Workflows: Run Tenant‑Specific Workflows on Demand

ux
by Luís Duarte · Cloudflare

Implement the @cloudflare/dynamic-workflows library and a Worker Loader to route tenant workflows dynamically.

What to do now

Add @cloudflare/dynamic-workflows to your project, create a Worker Loader that loads tenant code, and register the DynamicWorkflow binding in wrangler.jsonc.

Summary

Cloudflare has released the @cloudflare/dynamic-workflows library, a 300‑line TypeScript package that lets a single Worker—called the Worker Loader—route every create() call to tenant‑specific code and ensure the Workflows engine dispatches run(event, step) back to that same tenant’s code. The Worker Loader loads tenant code on demand, wrapping the WORKFLOWS binding with tenant metadata so that the engine can later resume execution in the correct context. Tenants write normal Workflow code, unaware of the dynamic dispatch, and can use all existing Workflow features such as status(), pause(), retries, step.sleep(), and step.waitForEvent().

The pattern mirrors earlier Cloudflare primitives: Dynamic Workers for compute, Durable Object Facets for storage, and Artifacts for source control. By separating the Worker Loader from the tenant code, the platform can support per‑tenant workflows without redeploying the entire application. The library handles RPC stubs, metadata routing, and ensures that the Workflows engine can persist and later resume tenant workflows across failures or redeployments.

This capability enables SaaS platforms and CI/CD products to ship tenant‑specific long‑running logic that survives across requests, making it easier to build agentic services that require durable execution.

Key aspects include the use of wrapWorkflowBinding to inject tenant metadata, the ability to load tenant modules via fetchTenantCode, and the requirement to export DynamicWorkflowBinding from the Worker Loader so the runtime can instantiate per‑tenant stubs.

Key changes

  • Introduced @cloudflare/dynamic-workflows library for dynamic tenant routing
  • Worker Loader loads tenant code on demand and wraps WORKFLOWS binding with tenant metadata
  • Tenants write normal Workflow code unaware of dynamic dispatch
  • Engine persists tenant metadata to resume execution later
  • Supports all existing Workflow features (status, pause, retries, sleep, waitForEvent)
  • Separates Worker Loader from tenant code, enabling per‑tenant workflows without redeploy
  • Requires export of DynamicWorkflowBinding for runtime RPC stubs
  • Facilitates SaaS and CI/CD platforms to ship tenant‑specific durable logic

Affects

internal

Customer impact

Analyzing matches…

Ask about this story

Impact on an agency? Which customers? Compare historically Risks of waiting