The Problem: Real Tasks Are Not Straight Lines
So far every app we built went in one direction: prompt, model, parser. Real tasks are messier.
The issue
We want an AI that writes a blog post and checks it before showing it to the user.
The first try
A chain: the writer writes, the reviewer reviews, we show the result.
Why it fails
The reviewer says “too long, rewrite it”. A chain only moves forward. It cannot send the draft back to the writer.
The fix
We need steps that can go back and try again, and one place where all the steps keep their notes. A graph gives us both.
Four Levels of AI Apps
We have already climbed three steps. LangGraph is the fourth.
| Level | What it is | The flow | The limit |
|---|---|---|---|
| GenAI | one prompt, one answer | prompt → LLM → text | no memory, no tools |
| LangChain | steps joined in a chain | prompt → LLM → parser | moves forward only |
| Tool calling | the model picks tools in a loop | think → act → observe | one loop, little control |
| LangGraph | you draw the whole flow | steps, loops, memory, pauses | you design it, so it takes more work |
What Is LangGraph?
DefinitionLangGraph is a library for building AI apps as a graph: steps joined by arrows, with a shared notebook that every step can read and write.
It has three building blocks.
State
The shared notebook
Every step reads it and writes to it. In your code it is a dictionary with fixed keys.
Node
A worker step
A normal Python function. It reads the state and returns only the keys it changes.
Edge
An arrow
It says which step runs next. An edge can also choose between two steps.