Most agent demos run once and vanish. LangGraph gives your agent a memory, a save point, and a stop sign a human can press before anything risky happens.
See the workflow in action, tap through the tabs below:
$ quick setup
pip install -U langgraph # then, in your script: from langgraph.graph import StateGraph, START, END from langgraph.checkpoint.memory import InMemorySaver
$ a node that stops and asks a human
from langgraph.types import interrupt
def approval_node(state):
ok = interrupt("Restart prod-api-2? (yes/no)")
return {"approved": ok}
$ pause, then resume the same thread
from langgraph.types import Command
graph = builder.compile(checkpointer=InMemorySaver())
cfg = {"configurable": {"thread_id": "incident-42"}}
graph.invoke({"task": "restart prod-api-2"}, cfg) # pauses
graph.invoke(Command(resume=True), cfg) # continues
$ read before you ship
Resume re-runs the whole node. Anything before interrupt() executes again, so keep it idempotent. Never wrap interrupt() in try/except, it works by raising an exception. Use a database-backed checkpointer in production, InMemorySaver forgets everything when the process dies.
What LangGraph actually is
LangGraph is a low-level orchestration framework for building stateful agents. You describe your agent as a graph: nodes are plain functions that read and update shared state, edges decide what runs next. The payoff is the stuff most agent demos skip, namely persistence, pauses for human approval, and the ability to resume after a crash. If you have read our OpenAI Agents SDK tutorial or the CrewAI crew walkthrough, think of LangGraph as the framework where you hold the steering wheel instead of the framework deciding the route for you.
For DevOps and security people that matters. An agent that touches production needs checkpoints, an audit trail of state, and a human who can say no. LangGraph builds those in as first-class ideas rather than bolting them on.
Quick setup
You need Python and one install. The official overview gives the command:
pip install -U langgraph
Here is the smallest possible graph, straight from the docs pattern. One node, a start edge, an end edge, compile:
from langgraph.graph import StateGraph, MessagesState, START, END
def mock_llm(state: MessagesState):
return {"messages": [{"role": "ai", "content": "hello world"}]}
graph = StateGraph(MessagesState)
graph.add_node(mock_llm)
graph.add_edge(START, "mock_llm")
graph.add_edge("mock_llm", END)
graph = graph.compile()
That is the whole skeleton. Everything else in this post is just more nodes, smarter edges, and a save point.
The mindset: graphs, not prompts
Stop thinking "one giant prompt that does everything." Think in small steps with explicit state between them. Each node does one job: gather evidence, propose a fix, ask for approval, apply the fix, write the report. The state object is your single source of truth, so when something goes wrong you can see exactly what the agent knew at each step.
Three rules I follow. Keep nodes small and boring. Put every risky action behind its own node so you can gate it. And store facts in state, not in the model's memory of the conversation.
Six workflows worth building
1. Approval gate before any production change
The flagship pattern. Pause the graph, show a human what is about to happen, continue only on a yes. LangGraph does this with interrupt():
from langgraph.types import interrupt, Command
def approval_node(state):
ok = interrupt("Restart prod-api-2? (yes/no)")
return {"approved": ok}
2. Resume a paused run on the same thread
Interrupts need a checkpointer and a thread ID. Same thread ID means same saved state, a new one means a fresh run:
from langgraph.checkpoint.memory import InMemorySaver
graph = builder.compile(checkpointer=InMemorySaver())
cfg = {"configurable": {"thread_id": "incident-42"}}
graph.invoke({"task": "restart prod-api-2"}, cfg)
graph.invoke(Command(resume=True), cfg)
3. Incident triage assistant
Nodes pull recent alerts, summarize logs, and propose a ranked list of likely causes. No write access at all. Example prompt for the summarizer node: "Given these 200 log lines, list the three most likely root causes with the line numbers that support each."
4. Dependency and CVE review
One node reads a lockfile, another looks up advisories, a third drafts upgrade notes. A human approves before any pull request opens. Great for the boring Monday-morning patch review nobody wants.
5. Runbook executor with checkpoints
Turn a ten-step runbook into ten nodes. If step seven fails, the checkpoint means you resume from step seven, not from scratch. That is durable execution doing real work for you.
6. Access request reviewer
The agent compares a request against policy text and recommends approve or deny with reasons. The final decision always routes through an interrupt to a human owner, because access decisions are not something to automate blind.
Safety and gotchas
The interrupts docs spell out the traps, and they are worth memorizing:
- Resume restarts the whole node. Any side effect before interrupt() runs again. Make it idempotent, use an upsert instead of a create.
- Do not wrap interrupt() in try/except. It works by raising an exception, so a bare except will swallow your pause.
- Keep interrupt order deterministic. Multiple interrupts in one node must fire in the same order every time.
- Pass JSON-friendly values only. Strings, dicts, and booleans, not functions or class instances.
- InMemorySaver is for development. Use a database-backed checkpointer in production or your paused runs vanish on restart.
Beyond the framework, give each agent the least privilege it needs. A triage node does not need write credentials. Log every approval with who said yes and when.
Usage and cost tips
The framework itself is open source, so your real costs are model calls and any hosting. Use a small, cheap model for classification and summarizing nodes, and save the stronger model for the one node that needs real reasoning. Cache evidence in state so a resumed run does not repeat expensive calls. LangGraph pairs with LangSmith for tracing and observability, which is worth switching on early so you can see where tokens go. Check current LangSmith plans on the vendor site before you budget, since I did not verify pricing here.
FAQ
Is LangGraph the same as LangChain?
No. LangGraph is a separate orchestration framework focused on stateful, long-running agents. It can work alongside LangChain components but you install and use it on its own.
Do I need a checkpointer for human-in-the-loop?
Yes. The docs say a persistence layer is mandatory for interrupts, because the checkpointer writes the exact graph state so you can resume later. Use InMemorySaver to learn and a database-backed one for production.
Is LangGraph good for DevOps and security automation?
It is a strong fit when you want approval gates, resumable runbooks, and an auditable state trail. For a quick one-shot script, a plain function is still simpler.
Your next move
Build the approval gate from workflow one this week, point it at something harmless, and watch a graph pause and resume. Want a guided path through AI agents for DevOps and security careers? Take a look at our courses and keep climbing.


