Introduction

MDWR (Memory-Driven Workflow Runtime) combines workflow orchestration with operational decision memory to create workflows that remember, explain, and learn from every decision.

What is MDWR?

MDWR enables developers to build workflows that:

Core Concepts

1. Workflow

A workflow is a sequence of steps that execute in order. Each step can make decisions based on input, state, and historical memory.

const workflow = Workflow.create("my_workflow_v1")
  .step("step1", handler1, true)
  .step("step2", handler2, true);

2. Step

A step is an executable unit that can make decisions. Steps that require decisions must return:

{
  decision: string;
  reason: string;
  confidence?: number;
  metadata?: object;
}

3. Execution

An execution is a single run of a workflow. You can pause, resume, and replay executions.

const execution = await workflow.execute({ userId: "u123" });
await execution.replay({ mode: "policy-aware" });

4. Memory

Memory stores every decision with context, allowing workflows to learn from history.

const insights = await ctx.memory.similar({
  situation: "my_decision",
  context: ctx.input
});

5. Events

Events signal workflow lifecycle and step completion, enabling event-driven architectures.

Architecture

MDWR uses:

Developer SDK → MDWR Control Plane → Motia Runtime + Mem0/Redis

Next Steps