Graph hot-reload

Swap a registered graph definition with compile({ replace: true }). In-flight runs keep their old defHash and fail on advance.

Pattern

hot-reload.ts
import { graph } from "@monorch/ai";

const v1 = graph("hot")
  .node("prep", async () => "v1")
  .interrupt("hold")
  .compile({ replace: true });

const run = await v1.start({ n: 1 }); // waitingInterrupt

graph("hot")
  .node("prep", async () => "v2")
  .interrupt("hold", { prompt: "changed?" })
  .compile({ replace: true });

await run.resume("approved"); // throws — defHash mismatch
// run.status === "failed"

Notes

Omit replace to reject duplicate graph names. Use replace in dev hot-reload, not for mutating live customer runs mid-flight.

FAQ