LangGraph Explained: How GenAI Engineers Build Stateful, Multi-Agent Systems
LangGraph is a low-level orchestration framework and runtime for building stateful, long-running AI agents. You model your application as a graph: a typed state object, nodes that read and update it, and edges that decide what runs next. Its defining capability is durable execution, since a checkpointer saves state after every step, so an agent can pause for human approval, survive a crash, and resume exactly where it stopped. It is used when a standard tool-calling loop is not enough: custom control flow, multi-agent coordination, and workflows that mix deterministic code with model-driven decisions. As of August 2026 the current version is LangGraph 1.2.11, requiring Python 3.10 or higher.
The mental shift that makes LangGraph click: you are not configuring an agent, you are designing a state machine that happens to have a model inside it.
Your roadmap to becoming a Generative AI Engineer
See what you already know, what to learn next and how long the switch to a GenAI engineering role takes. Tap any step for what to study and build.
What's inside8 stages · 30 steps to job-ready
- Python & engineering foundations
- ML & deep learning essentials
- How LLMs work
- Prompting & building LLM apps
- RAG & model customisation
- Agents & tool use
- Production, evaluation & safety
- Portfolio & job readiness
Python & engineering foundations
What to study
- Core Python: data types, functions, classes, modules
- Virtual environments and package management (pip, uv)
- Writing clean, testable scripts
What to build
A command-line script that reads a CSV, cleans it and writes a summary report.
What to study
- SQL joins, aggregations and window functions
- pandas for cleaning and reshaping data
- Working with text data at scale
What to build
A notebook that cleans a messy text dataset and prepares it for a model.
What to study
- Git branching and pull requests
- How REST APIs work: HTTP methods, status codes, auth headers
- Reading and writing JSON
What to build
Call a public API from Python, handle errors and save the results as JSON.
What to study
- Vectors, matrices and dot products
- Probability and distributions
- Gradients and optimisation, intuitively
What to build
Implement cosine similarity and gradient descent from scratch in NumPy.
ML & deep learning essentials
What to study
- Supervised vs unsupervised learning
- Train/test splits, overfitting and evaluation metrics
- scikit-learn workflows
What to build
Train and evaluate a text classifier with scikit-learn.
What to study
- Tokenisation and text preprocessing
- Word embeddings and semantic similarity
- Sequence models (RNN, LSTM) and why transformers replaced them
What to build
Build a semantic search over 500 short texts using sentence embeddings.
What to study
- Layers, activations, loss functions and backpropagation
- Training loops, batching and GPUs
- PyTorch tensors and autograd
What to build
Train a fully connected network on a small dataset and plot its learning curve.
How LLMs work
What to study
- Self-attention and multi-head attention
- Encoder, decoder and encoder-decoder models
- Positional encoding and why scale matters
What to build
Walk through a minimal transformer implementation and explain each block in a short write-up.
What to study
- The Transformers library, model hub and datasets
- Running open-weights models locally
- Fine-tuning a pre-trained model for a task
What to build
Fine-tune a small pre-trained transformer for sentiment or topic classification.
What to study
- Closed vs open-weights model families
- Tokens, context windows, temperature and sampling
- Comparing models on cost, latency and quality
What to build
A comparison table of three models answering the same 20 prompts, with cost and latency.
What to study
- Quantisation, pruning and distillation
- When a small model beats a large one
- On-device and low-cost inference
What to build
Quantise an open model and compare its speed and quality against the original.
Prompting & building LLM apps
What to study
- System prompts, few-shot examples and chain-of-thought
- Prompt test sets and versioning
- Reducing hallucinations through prompt design
What to build
A prompt library with a 30-example test set and before/after scores.
What to study
- Calling LLM APIs: streaming, rate limits, keys
- Serving with FastAPI and simple UIs with Streamlit
- Caching and cost control
What to build
A small chat app with streaming responses, deployed for others to try.
What to study
- JSON schema outputs and validation
- Function / tool calling
- Retries and graceful failure
What to build
An invoice or resume parser that returns validated JSON.
What to study
- Chains, prompts and output parsers
- Document loaders and retrievers
- When a framework helps and when it gets in the way
What to build
Rebuild your chat app with LangChain and compare the code with your plain-API version.
RAG & model customisation
What to study
- Embedding models and similarity search
- Vector databases (e.g. pgvector, Pinecone, Weaviate)
- Chunking strategies and metadata filters
What to build
Index a document set in a vector database and query it with filters.
What to study
- Supervised fine-tuning vs prompting vs RAG
- LoRA and other parameter-efficient methods
- Preparing instruction datasets
What to build
LoRA fine-tune an open-weights model on a narrow task and compare it with prompting alone.
What to study
- Vision transformers and CLIP-style models
- Image captioning and visual question answering
- Combining text and image retrieval
What to build
An image search app that finds photos from a text description.
What to study
- The RAG pipeline end to end
- Re-ranking, hybrid search and citations
- Measuring retrieval quality
What to build
A document Q&A assistant that cites its sources, with a retrieval-quality report.
What to study
- Instruction tuning and reward models
- RLHF and DPO, conceptually and with TRL
- Where alignment fits in real products
What to build
Train a small reward model and run a preference-tuning loop on a toy task.
Agents & tool use
What to study
- ReAct, planning and reflection patterns
- Single-agent vs multi-agent setups
- Memory: short-term, long-term and retrieval
What to build
A research agent that searches, reads and summarises sources on a topic.
What to study
- Model Context Protocol (MCP) servers and clients
- Connecting agents to databases, CRMs and internal APIs
- Permissions and audit trails for tool calls
What to build
An MCP server that exposes two tools from a real API, used by your agent.
What to study
- Graphs, state and checkpoints
- Human-in-the-loop approvals
- Error handling in multi-step workflows
What to build
Rebuild your research agent as a LangGraph workflow with an approval step.
Production, evaluation & safety
What to study
- Docker images for AI apps
- CI/CD basics
- Secrets and environment configuration
What to build
Containerise your RAG assistant and deploy it with a CI pipeline.
What to study
- Building evaluation datasets
- LLM-as-judge and its limits
- Regression testing prompts and models
What to build
An eval harness that scores your assistant on 50 cases and runs on every change.
What to study
- Tracing LLM calls
- Tracking token cost and latency
- Dashboards and alerting
What to build
Add tracing and a cost dashboard to your deployed app.
What to study
- Managed model platforms on AWS, GCP and Azure
- Serverless deployment and autoscaling
- Data privacy and region choices
What to build
Deploy your app on one cloud using a managed model endpoint.
What to study
- Hallucination, bias and privacy risks
- Prompt injection and defences
- PII handling and content filtering
What to build
Add input and output guardrails to your assistant and document the risks you tested.
Portfolio & job readiness
What to study
- GenAI system design questions
- Explaining trade-offs: RAG vs fine-tuning, cost vs quality
- Coding rounds in Python
What to build
Mock-interview notes for three GenAI system design questions.
What to study
- Choosing a domain problem (healthcare, fintech, edtech)
- Writing clear READMEs and architecture notes
- Recording a short demo
What to build
A client-ready AI agent for one domain, with a public demo and write-up.
Fine-tuned text classifier
Adapting a pre-trained transformer to a real task.
Fine-tune a small pre-trained transformer on a labelled dataset, evaluate it properly and compare it with a classic ML baseline.
Structured data extractor
Turning messy documents into clean JSON.
Use an LLM API with schema-validated outputs to extract fields from invoices or resumes, with a prompt test set to track accuracy.
Document Q&A assistant
Retrieval-augmented answers with citations.
Index a document collection in a vector database and build an assistant that answers questions with cited sources and a retrieval-quality report.
LoRA fine-tune of an open model
Customising a model when prompting isn't enough.
Fine-tune an open-weights model with LoRA on a narrow task and document when it beats prompting and RAG, and when it doesn't.
Reward model & preference tuning
Teaching a model what good looks like.
Train a small reward model on preference data and run a preference-tuning loop, with a write-up of what changed.
Multimodal image search
Finding images from plain-language descriptions.
Embed images and text in a shared space and build a search app that retrieves photos from a description.
Tool-using research agent
An agent that plans, acts and asks for approval.
Build a LangGraph agent that searches, reads and summarises sources, calls tools through an MCP server and pauses for human approval.
Deployed GenAI service
From notebook to a monitored production API.
Containerise an LLM app, deploy it on a cloud platform with CI/CD, and add tracing plus a cost and latency dashboard.
Eval harness with guardrails
Proving your AI app works, and stays safe.
Create a 50-case evaluation set, automate scoring on every change, and add input and output guardrails against prompt injection and PII leaks.
Domain AI agent capstone
A client-ready agent for a real industry problem.
Pick a domain such as healthcare, fintech or edtech and ship an agent that combines retrieval, tools, evals and guardrails, with a public demo and write-up.
GenAI glossary 17 terms
Tap a term to see what it means. You will hear these in every GenAI interview.
- LLM
- Large language model: a neural network trained on huge amounts of text to predict and generate language.
- Transformer
- The neural network architecture behind modern LLMs, built around the attention mechanism.
- Token
- A chunk of text (often part of a word) that a model reads and writes. Pricing and limits are counted in tokens.
- Context window
- The maximum number of tokens a model can consider at once, including your prompt and its answer.
- Prompt engineering
- Designing instructions and examples so a model reliably produces the output you need.
- Embeddings
- Numeric vectors that capture meaning, so similar texts end up close together.
- Vector database
- A database built to store embeddings and find the most similar ones quickly.
- RAG
- Retrieval-augmented generation: fetching relevant documents and giving them to the model so answers are grounded.
- Fine-tuning
- Further training a pre-trained model on your own data to specialise it.
- LoRA
- Low-rank adaptation: a parameter-efficient fine-tuning method that trains small add-on weights instead of the whole model.
- Agent
- An LLM system that plans steps, calls tools and acts towards a goal, often over several turns.
- Tool calling
- Letting a model call functions or APIs, such as search or a database query, with structured arguments.
- MCP
- Model Context Protocol: an open standard for connecting AI applications to tools and data sources.
- Evals
- Systematic tests that measure how well an AI system performs on representative cases.
- Guardrails
- Checks on inputs and outputs that keep an AI system safe, on-topic and compliant.
- Hallucination
- When a model states something false or unsupported with confidence.
- Prompt injection
- An attack where malicious text tricks a model into ignoring its instructions.
Close your gaps with a structured programme
The Certificate Programme in Generative AI from CEP, IIT Delhi covers transformers, fine-tuning, RAG, agents and responsible AI through live weekend classes and hands-on projects.
Key Takeaways
- LangGraph is a runtime, not a framework layer competing with LangChain. create_agent compiles into it.
- State plus reducers is the core abstraction. Get the reducer wrong and nodes silently overwrite each other.
- Checkpointers are what make durability, human-in-the-loop and time travel possible. They are one argument.
- Multi-agent has five documented patterns, and most teams need fewer agents than they think.
- The most expensive mistake is using LangGraph when create_agent would have worked.
What LangGraph Actually Is
LangGraph models an agent workflow as a graph with three parts, and that is genuinely the whole model:
State. A shared data structure representing the current snapshot of your application, defined as a TypedDict, a dataclass if you want defaults, or a Pydantic model if you need recursive validation. Every node reads it and returns updates to it.
Nodes. Plain Python functions that take state, do work, and return an update. A node can call a model or it can be ordinary code. The docs are blunt on this point: nodes and edges “are nothing more than functions, they can contain an LLM or just good ol’ code”.
Edges. Functions that decide what runs next based on the current state. Fixed transitions or conditional branches.
In short: nodes do the work, edges decide what happens next.
Execution follows a message-passing model inspired by Google’s Pregel system. The graph proceeds in discrete super-steps, where nodes running in parallel share a super-step and sequential nodes occupy separate ones. Execution ends when no node is active and no messages are in transit. You rarely need this detail day to day, but it explains parallel behaviour when you branch.
The minimum viable graph, from the current docs:
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()
graph.invoke({"messages": [{"role": "user", "content": "hi!"}]}) Note the compile step. It validates structure, checking for orphaned nodes and similar problems, and it is where checkpointers and breakpoints are attached. You must compile before you can run.
Its relationship to LangChain, stated once. LangChain is the framework, LangGraph is the runtime beneath it, and create_agent returns a compiled LangGraph graph. If you want the full argument about which to reach for, the LangChain vs LangGraph breakdown covers the decision properly, and the LangChain pillar guide covers the framework layer. This article stays at the runtime.
State and Reducers: Where Most Bugs Live
This is the part that separates working graphs from mysterious ones, and most tutorials skim it.
Your state schema defines what flows through the graph. Reducers define how updates are applied. When two nodes both return an update to the same key, the reducer decides whether the second overwrites the first or combines with it.
The default is overwrite. For a message list, overwrite is almost always wrong: you want to append. That is why MessagesState exists as a prebuilt schema with the right reducer already attached.
from typing import TypedDict, Annotated
from operator import add
class State(TypedDict):
messages: Annotated[list, add] # appends
current_step: str # overwrites The failure mode to recognise: you add parallel branches, both write to the same key, and results vanish non-deterministically depending on which finished last. It presents as a model problem. It is a reducer problem.
You can also constrain what enters and leaves the graph using separate input and output schemas, plus private channels for internal node communication that never appear in the output. Useful once a graph grows past a handful of nodes.
One documented limitation worth knowing: the higher-level create_agent factory does not support Pydantic state schemas. If you need recursive validation on state, you are writing the graph yourself.
How to Build AI Agents With LangGraph
This section covers the how to build ai agents intent with the sequence that actually works.
Step 1: Write the state schema first. Not the nodes. Ask what information has to survive between steps, and what happens when two steps write the same field. Getting this wrong is the most expensive early mistake because everything downstream depends on it.
Step 2: Write nodes as testable functions. A node takes state and returns a dict of updates. Keep model calls thin and put logic in ordinary code where you can unit test it without an API key.
Step 3: Add edges, conditional where routing depends on state. A conditional edge is a function returning the name of the next node. This is where LangGraph earns its keep over a plain loop.
Step 4: Compile with a checkpointer. Even in development. It costs one argument and unlocks resumption, inspection and human-in-the-loop.
Step 5: Invoke with a thread_id. The thread ID is your persistent cursor. Reuse it and you resume that state. Use a new one and you start fresh with empty state.
Step 6: Trace it. A graph that misbehaves is nearly impossible to debug from output alone, because the interesting information is in which nodes ran, in what order, with what state. Set LANGSMITH_TRACING=true or accept that you will be guessing.
Prerequisites: Python 3.10 or higher, and comfort with typed Python, since the state schema is a type definition. If agents as a concept are still fuzzy, what AI agents are is the better starting point, because LangGraph assumes you already know what you are orchestrating.
Before you write a graph, apply this test: does your flow need a cycle, branching on intermediate state, durability across restarts, or human approval mid-run? If none apply, create_agent is the correct choice and a hand-written graph is over-engineering that reviewers will flag.
Persistence: Checkpointers, Stores and Durable Execution
Durability is LangGraph’s strongest differentiator, and it comes from two distinct systems that are easy to confuse.
| Checkpointer | Store | |
| Persists | Graph state snapshots | Application-defined key-value data |
| Scope | A single thread | Across threads |
| Memory type | Short-term, thread-scoped | Long-term, cross-thread |
| Use for | Conversation continuity, human-in-the-loop, time travel, fault tolerance | User preferences, facts, shared knowledge |
| Access | Pass a thread_id in config | Read and write from nodes or app code |
Most real applications use both: the checkpointer tracks the current conversation, the store remembers the user between conversations.
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.store.memory import InMemoryStore
graph = builder.compile(checkpointer=InMemorySaver(), store=InMemoryStore())
result = graph.invoke(
{"messages": [{"role": "user", "content": "Hi, my name is Bob."}]},
{"configurable": {"thread_id": "thread-1"}},
) Four production traps, all documented, all common:
- MemorySaver and InMemorySaver lose everything on restart. They are RAM only. Use PostgresSaver in production or SqliteSaver for local file-based work.
- thread_id has a length limit. Under 255 characters with PostgresSaver, or you get a database error. Use a UUID.
- Checkpoints grow without bound. Long conversations accumulate state, raising latency and storage cost. Prune on a schedule or set a retention policy. Nothing does this for you.
- Subgraphs keep their own checkpoint namespace, so a parent graph may not immediately see a subgraph’s state updates. Use a Store for data that must cross graph boundaries.
That third one is a slow-burn production issue rather than a launch-day bug, which is exactly why it catches teams months in.
Human-in-the-Loop With Interrupts
Interrupts are the feature that makes LangGraph viable for workflows touching money, customer data or anything irreversible.
Calling interrupt() inside a node pauses execution, saves state via the checkpointer, and waits indefinitely until you resume. Unlike static breakpoints that pause before or after a named node, interrupts are dynamic: they can sit anywhere in your code and fire conditionally.
from langgraph.types import interrupt
def approval_node(state: State):
approved = interrupt("Do you approve this action?")
return {"approved": approved}
You resume by re-invoking with a Command, and the resume value becomes the return value of the interrupt() call inside the node:
from langgraph.types import Command
config = {"configurable": {"thread_id": "thread-1"}}
stream = graph.stream_events({"input": "data"}, config=config, version="v3")
final = stream.output
if stream.interrupted:
print(stream.interrupts)
resumed = graph.stream_events(Command(resume=True), config=config, version="v3") The gotcha that causes real bugs: when you resume, the node restarts from the beginning, so any code before the interrupt() call runs a second time. If that code charges a card, sends an email or writes a row, it happens twice. Put side effects after the interrupt, or make them idempotent.
Two more rules worth internalising. You must resume with the same thread_id used when the interrupt occurred. And Command(resume=…) is the only Command form intended as input to invoke or stream; the update, goto and graph parameters are for returning from node functions, not for continuing a conversation.
Interrupts require a checkpointer and a thread ID. Without persistence there is nothing to resume into.
Multi-Agent Systems: Five Patterns, and When You Need None
The multi-agent systems intent attracts more enthusiasm than it deserves, so start with the documentation’s own caveat: not every complex task needs multiple agents, and a single agent with the right tools and prompt often achieves the same result.
When teams say they need multi-agent, they usually want one of three things: context management (specialised knowledge without flooding the context window), distributed development (separate teams owning separate capabilities), or parallelisation (concurrent workers on subtasks).
Multi-agent genuinely helps when a single agent has too many tools and chooses badly between them, when tasks need extensive domain-specific context, or when you must enforce sequential constraints.
The five documented patterns:
| Pattern | How it works | Best for |
| Subagents | A main agent coordinates subagents as tools, all routing through the main agent | Distributed development, parallelisation, multi-hop |
| Handoffs | Agents transfer control via tool calls that update state and trigger routing | Multi-hop work and direct user interaction |
| Skills | One agent stays in control, loading specialised prompts and knowledge on demand | Distributed development with direct user interaction |
| Router | A classification step directs input to specialised agents, results synthesised | Parallelisation of clearly separable inputs |
| Custom workflow | Bespoke LangGraph flow mixing deterministic and agentic steps, other patterns embedded as nodes | Anything the four above cannot express |
Two things this table implies that are worth saying outright. Subagents scale poorly for direct user interaction, since everything routes through the coordinator. And the Skills pattern is not really multi-agent at all, which is often the point: it solves the context problem without the coordination cost.
At the centre of all of this is context engineering, deciding what each agent actually sees. That, more than topology, determines whether a multi-agent system works.
The cost dimension people discover late. Every additional agent means more model calls and more tokens processed. A coordinator that consults three subagents can multiply cost and latency several times over for a request a single well-tooled agent would have handled in one call. Multi-agent is a context and organisation solution, not a quality upgrade you get for free. For how this compares across the wider ecosystem, this guide to AI agent frameworks covers the landscape.
What LangGraph Does Not Give You
- It does not abstract prompts or architecture. This is stated as a design choice. LangGraph provides infrastructure, and the reasoning quality of your agent remains entirely your problem.
- It does not tell you your agent is wrong. Durable execution will faithfully resume a broken workflow. You still need evaluation, and the judgment about what correct means is yours.
- It does not control cost. Cycles are the point of the framework and an unbounded cycle is an unbounded bill. Set limits explicitly.
- It does not make graph thinking optional. The steeper learning curve is real. If your team has never designed a state machine, budget for that rather than for the API surface, which is small.
Where This Sits in Your Skill Stack
For an engineer with a few years of experience, LangGraph is worth learning for a reason beyond the framework itself: it is one of the few places in the GenAI stack where classical engineering skill transfers directly. Professionals looking to master these production patterns can explore the IIT Delhi generative AI course to build practical expertise in multi-agent architectures.
State design, idempotency, retry semantics, durable execution, checkpoint pruning: these are distributed-systems problems wearing new names. An engineer who has built a job queue or a workflow engine already understands the hard parts. The system design fundamentals that apply to any stateful service apply here almost unchanged, which is why backend engineers often move into agent infrastructure faster than people expect.
That is also the honest career read. The scarce skill is not knowing the graph API, which is a weekend. It is knowing when a workflow needs durability, how to design state that survives concurrent writes, and how to keep an agent’s cost bounded under load. Those judgments outlast the framework. The AI engineer roadmap sequences this against the rest of the stack.
Build one graph that does something unglamorous and complete: a workflow that pauses for approval, survives a deliberate process kill, and resumes correctly. Kill the process halfway through and restart it. That single exercise teaches more about production agents than any number of multi-agent demos, and it is the thing an interviewer can probe for ten minutes without hitting the bottom of your understanding.
Conclusion
LangGraph is the layer you reach for when your agent stops being a loop and starts being a system. State that must be designed, execution that must survive failure, steps that must wait for a human, and work that must be split across specialised components.
The framework itself is small. A state schema, nodes, edges, a compile step, a checkpointer. What takes real skill is deciding whether you need it at all, because the most common LangGraph mistake is not writing a bad graph, it is writing a graph where three arguments to create_agent would have done the job.
Build one durable workflow, kill the process mid-run, and watch it resume. That is the moment the abstraction stops being theory.
Frequently Asked Questions
A runtime for building agents as state machines. You define a state object, functions that update it, and rules for what runs next. It saves state at every step, so agents can pause, resume and survive crashes.
They are different layers, not competitors. LangGraph is the runtime that LangChain’s agents compile down to. Use LangChain’s create_agent for standard tool-calling loops and drop to LangGraph when you need control the loop cannot give you.
The library is open source and free. LangSmith for tracing and evaluation, and the managed deployment platform, are separate commercial products with free tiers. Model API costs are separate and usually dominate.
Your persistent cursor into saved state. Reusing a thread ID resumes that conversation from its last checkpoint. A new value starts a fresh thread with empty state. Keep it under 255 characters when using PostgresSaver.
Yes, that is a core use case. With a durable checkpointer the graph persists after every step, so a workflow can run for extended periods, survive failures, and resume where it stopped.
How many agents should a multi-agent system have?
Fewer than you initially plan. Start with one agent and add another only when you can name the specific problem it solves: too many tools for reliable selection, context that will not fit, or teams that need independent ownership.
The current 1.x line, which is 1.2.11 as of August 2026, requiring Python 3.10 or higher. Check publication dates on tutorials, since the surrounding LangChain ecosystem reset in late 2025 and much older material teaches deprecated patterns.