HITL refund
Pause a graph at an interrupt, persist the checkpoint, resume later from another HTTP request. Works the same in Fastify, Hono, or any BYO server.
Pattern
hitl-refund.ts
typescript
import { graph, memorySaver } from "@monorch/ai";
// import { postgresCheckpointer, ensureMonorchSchema } from "@monorch/ai/postgres";
const checkpointer = memorySaver(); // or postgresCheckpointer(pool) after ensureMonorchSchema
const refund = graph("refund")
.node("lookup", async ({ input }) => ({
output: `order:${input.orderId}`,
state: { orderId: input.orderId },
}))
.interrupt("approve", { prompt: "Approve refund?" })
.node("pay", async ({ outputs }) => `refunded:${outputs.lookup}`)
.compile({ checkpointer });
// request A
const started = await refund.start({ orderId: "ord_9" }, { threadId: "t1" });
// started.status === "waitingInterrupt"
// request B (minutes later)
const run = await refund.restore("t1");
await run.drive(); // idempotent while waiting
const done = await run.resume("approved");Notes
Always pass threadId on start when you need restore. Without a checkpointer, restore throws CHECKPOINT_MISSING. See Checkpoints and Errors.
End-to-end HTTP samples: Fastify, Hono (examples/hono-npm).