Quickstart
In five minutes you will build a graph where an agent drafts a reply to a customer, the run stops for a human to review the draft, and then finishes.
1. Create the project
mkdir refund-desk && cd refund-desk
npm init -y && npm pkg set type=module
npm install @ailu-ai/graph-sdk
2. Write the graph
Save this as app.ts:
app.ts
import { createGraph, finalAnswer, model } from "@ailu-ai/graph-sdk";
const app = createGraph({ name: "refund-desk" })
.channel("request", { type: "string", default: "" })
.channel("reply", { type: "string", default: "" })
.agentNode("draft", {
model: model.anthropic("claude-sonnet-4-6"),
prompt: { system: "Draft a one-sentence reply to the customer's refund request." }
})
.humanGate("review") // the run stops here until a human approves
.node("send", async (_input, state) => ({ reply: finalAnswer(state.channels.agentResult) }))
.edge("draft", "review")
.edge("review", "send")
.compile();
// 1. Run: the agent drafts, then the run suspends at the gate.
const paused = await app.run({ request: "Please refund order #1024." });
console.log(paused.status); // "suspended"
console.log(finalAnswer(paused.channels.agentResult)); // the draft a human reviews
// 2. A human approved: resume from the checkpoint.
const done = await app.resume(paused.runId);
console.log(done.status); // "completed"
console.log(done.channels.reply);
What each part does:
channeldeclares a piece of run state. Nodes read channels and return the ones they change.agentNoderuns an LLM agent. It writes its result to theagentResultchannel;finalAnswer()reads the answer out of it.humanGatestops the run.run()returns with status"suspended".resumecontinues from the checkpoint saved at the gate.
3. Run it
With an Anthropic key:
ANTHROPIC_API_KEY=sk-ant-... npx tsx app.ts
Or offline, with the deterministic mock:
AILU_LLM_MOCK=1 npx tsx app.ts
You should see suspended, the draft, then completed and the reply.
What you just used
In a real app, the gap between run() and resume() is where a person reviews the draft in your
UI. Your server keeps the CompiledGraph and calls resume(runId) when they approve. To resume
in a different process, after a deploy or a restart, see
Long-running runs.
Next
- Give the agent a tool that needs approval: Tools and approval.
- Understand nodes, channels and edges: Graphs.
- See a complete app: Governed refund agent.