What Is LangGraph? Building AI Agents as Graphs, Explained With a Worked Example
What is LangGraph?
LangGraph is an open-source library from the LangChain team for building AI agents and multi-step workflows as graphs. You define a shared state, add nodes, which are plain functions that each do one step, and join them with edges that say what runs next. A fixed edge always goes to the same step; a conditional edge lets the model's reply pick the next step, which is what makes a graph an agent. LangGraph also saves progress after every step, so a run can survive a crash or pause for a person's approval, and LangChain's create_agent is itself built on it.
Answer last checked
Save your progress and get the AI Engineering cheat sheet PDF
This guide answers 10 questions about LangGraph: what it is, how it relates to LangChain, what state, nodes and edges are, what a simple graph and an agent graph look like, how loops and the recursion limit work, what happens after a crash, how to pause for a person and when to use it. The runs come from our Hands-On AIOps on AWS course on LangGraph 1.2.20, and the LangGraph docs are linked under each answer.
10 questions · 3 sections · answers from the course
These answers come from our course Agentic AI Engineering with LangChain, LangGraph and LangSmith: Build Real Agents, Hands-On: 38 video lessons are out now (Modules 0 to 4), about 692 minutes, of the 219 planned. Module 0 is free to watch with no sign-in.


The short version
LangGraph runs a flowchart of steps that share one notebook. The notebook is the state, the boxes are nodes and the arrows are edges. Fixed edges make a workflow and model-chosen edges make an agent, in the same graph. Put your stop rule in the router, not in the recursion limit, add a checkpointer so runs survive crashes, and use interrupt() where a person must approve.
1. What LangGraph is
LangGraph is a Python and JavaScript library for building AI agents and workflows as graphs. These answers explain the idea in plain words and where it sits next to LangChain.
What is LangGraph?
LangGraph is an open-source library from the LangChain team for building agents and multi-step AI workflows as graphs. You describe a shared state, add steps called nodes, and join them with edges that say what runs next. The graph can mix plain code steps with steps where a language model decides, and LangGraph runs it, saves its progress and lets you pause it for a person.
Its own overview describes it in those terms: workflows defined as graphs of shared state, nodes and edges, with deterministic steps and LLM-driven steps in the same graph.
Source: LangGraph docs, Overview
Lesson: Why build an agent as a graph: state, nodes and edges
Is LangGraph part of LangChain?
They are separate libraries from the same company, and since version 1.0 LangChain is built on top of LangGraph. LangChain's create_agent, the usual one-line way to make an agent, builds a small LangGraph graph with two nodes, model and tools, and runs it for you.
So you can start with create_agent and move to writing the graph yourself when you need fixed steps, branches, saved progress or human approval in exact places.
Lesson: Why build an agent as a graph: state, nodes and edges
What are state, nodes and edges in LangGraph?
Picture an incident flowchart on the wall and one shared notebook on the desk. The notebook is the state: one record for the whole run, with named keys. Each box is a node: a plain Python function that receives the state, does one piece of work and returns only the keys it changed. Each arrow is an edge: it says which node runs next. Every run starts at START and stops at END.
The Graph API page sums it up in one line: nodes do the work; edges decide what runs next. You build every graph in the same four moves: describe the state, add the nodes, add the edges and compile.
Source: LangGraph docs, Graph API
Lesson: Why build an agent as a graph: state, nodes and edges
2. A worked example: a workflow and an agent, both as graphs
In our Hands-On AIOps on AWS course the first LangGraph lesson builds an on-call checklist as a graph, then opens up an agent to show it is a graph too. Both were run with LangGraph 1.2.20.

What does a simple LangGraph graph look like?
Our first graph has three nodes and no model. look_at_pods finds the server that is not running and writes its name and status into the state, read_events reads the warnings about it, and write_note writes one line a person can act on. Fixed edges join START, the three nodes and END, so every run takes the same three steps and makes 0 model calls.
The agent from the same lesson, built with create_agent, is also a graph, with just two nodes, model and tools. Its run took 7 steps, with 4 model calls and 3 tool functions, because the model's replies chose the path. Those 4 calls cost $0.000384.
What we measured: LangGraph 1.2.20: first_graph.py 3 nodes, 3 steps, 0 model calls; create_agent's graph 2 nodes, 7 steps, 4 model calls, 3 tool functions; the four calls cost $0.000384.
Lesson: Why build an agent as a graph: state, nodes and edges
How does LangGraph build both workflows and agents?
With two kinds of edges. A fixed edge, added with add_edge, always goes to the same node. A conditional edge runs a small function that reads the state and returns the name of the next node. In an agent, that function reads the model's last reply: if it asks for a tool, the next node is tools; if not, the next node is END.
A graph of fixed edges only is a workflow that takes the same path every time. When the model's reply picks the edge, the graph is an agent. One graph can hold both, so the steps that must never be skipped stay fixed and only the uncertain part is left to the model.
Source: LangGraph docs, Graph API
Lesson: Why build an agent as a graph: state, nodes and edges
How do loops and the recursion limit work in LangGraph?
An edge can point back to an earlier node, which makes a loop, such as check, wait, check again. LangGraph stops any run that goes past its recursion limit with a GraphRecursionError. The docs say the default, since version 1.1.4, is 10,007 steps, and many older guides still say 25.
In our lesson, a loop with no stop rule made 5,004 checks before that default stopped it. The limit is a safety net, not a stop rule: put the real stop in the router, such as at most three checks and then hand over to a person, and set a small recursion_limit as a backstop. A run of 6 rounds needs a limit of 7, not 6.
Source: LangGraph docs, Graph API
What we measured: watch_forever.py, LangGraph 1.2.20: 5,004 checks, then GraphRecursionError at the default limit of 10,007. watch_bounded.py: 6 rounds failed with recursion_limit 6 and finished with 7.
3. Saved progress, human approval and when to use LangGraph
The features that make teams pick LangGraph are about running agents for real: surviving a crash, pausing for a person and remembering across runs.
What happens to a LangGraph agent when the process crashes?
With a checkpointer, LangGraph saves the state after every round of a run, under a thread id. If the process dies, a new process can open the same thread and carry on from the last checkpoint; only unfinished work runs again.
In our lesson a run checked six apps in parallel and was killed in round 2, after five of the six checks had finished. The resumed run did only the one unfinished check. With a Postgres checkpointer, a second, separate process resumed the same thread from the database. Because a node can run twice after a crash, every node should be safe to repeat.
Source: LangGraph docs, Persistence
What we measured: LangGraph 1.2.20: process killed in round 2 after 5 of 6 checks finished; the resumed run ran only the unfinished check.
Lesson: Durable agents: checkpoints, a real crash, resuming and replaying
Can a LangGraph agent wait for a person to approve a step?
Yes. A node can call interrupt(), which saves the run with the checkpointer and stops it with a question for a person, such as whether to roll the web app back to its previous version. No program has to keep running while the person decides, for a minute or a day. Later, perhaps from a different process, your app resumes the same thread with the answer, passed in a Command, and LangGraph runs that node again from its first line with the answer in hand.
Two rules follow from that restart. Code before interrupt() runs twice, so never send a message or create a ticket there. And the node that acts on a yes should look at the system again first, because the world may have changed while the person was deciding.
Source: LangGraph docs, Interrupts
When should I use LangGraph instead of a simple agent?
Use create_agent or a plain loop when the job is one model with a few tools and nothing must happen in a fixed order. Move to LangGraph when some steps must always run, when you need to see and name each step, when a run must survive a crash or wait for approval, or when work splits into branches that run in parallel.
LangGraph adds concepts to learn, state, reducers, checkpointers and threads, so it pays off when the agent is going to production, not for a quick demo.
Lesson: Why build an agent as a graph: state, nodes and edges
How should I learn LangGraph?
In this order: build a small graph with no model so state, nodes and edges are clear; add a conditional edge and a loop with a stop rule; open up create_agent's graph and follow one run step by step; then add a checkpointer, crash a run on purpose and resume it; and finally add interrupt() for an approval step.
Run everything yourself and read what each step wrote into the state, because the state is where almost every LangGraph bug shows up.
Lesson: Why build an agent as a graph: state, nodes and edges
Where to go next
Everything on this page comes from Agentic AI Engineering with LangChain, LangGraph and LangSmith: Build Real Agents, Hands-On. 38 video lessons are out now (Modules 0 to 4), about 692 minutes, of the 219 planned. Module 0 is free to watch with no sign-in. Start with the free lessons before you decide.
These questions are a start. The interview asks more.
Get all 120 questions in the Agentic AI Engineering pack
Each question has why it is asked, a full answer, what the interviewer listens for, the follow-ups, the common mistakes and a diagram (153 diagrams in all). A PDF you keep, junior to staff level.
Pay by UPI, cards or netbanking through Razorpay. Pay by card or PayPal, in US dollars. Download at once from My packs.
