Generative AIby Dhruv Narang

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.

LevelWhat it isThe flowThe limit
GenAIone prompt, one answerprompt → LLM → textno memory, no tools
LangChainsteps joined in a chainprompt → LLM → parsermoves forward only
Tool callingthe model picks tools in a loopthink → act → observeone loop, little control
LangGraphyou draw the whole flowsteps, loops, memory, pausesyou design it, so it takes more work

What Is LangGraph?

Definition

LangGraph 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.

startWriteReviewendneeds a fixSTATE: the shared notebooktopic, draft, feedbackEvery step reads itand writes to it.
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.