They are three layers, not three rivals. LlamaIndex turns a messy corpus into something you can retrieve from. LangChain gives you integrations and a standard agent. LangGraph gives you control flow, state and durability, and since LangChain 1.0 it is what LangChain’s agents run on. Name the part of your system that is genuinely hard and adopt only the layer that owns it.
“Are we going LangChain or LlamaIndex? What about LangGraph?” The comparison feels natural because the names rhyme and the READMEs overlap. It is still the wrong question. It is like asking whether requests, SQLAlchemy or Celery is the best Python library: the answer depends on which part of the program you mean, and a real system often has all three parts.
What you are choosing between, in October 2026
Latest releases on PyPI on 2026-10-21: langchain 1.4.6, langgraph 1.2.16, llama-index-core 0.14.25. All need Python 3.10 or later.
The 1.0 releases moved the ground under most comparison posts. LangChain’s agent is now create_agent, customised with middleware (human-in-the-loop, summarisation, PII redaction) and built on the LangGraph runtime. The old chains (LLMChain and friends) moved to langchain-classic. Code from 2024 tutorials often will not import.
What each one is best at
- connectors, parsing, chunking, index types
- retrievers, postprocessors, query engines
- defaults chosen by people staring at messy PDFs
- one interface over many models, stores and tools
create_agent: a standard tool loop in a few lines- best while components are still changing
- typed state, nodes, conditional edges
- checkpoint after every node: resume, replay
interrupt()to wait for a person
The overlap is real and not where any of them is strongest. LlamaIndex ships an event-driven Workflows engine, LangChain ships retrievers. Choose on the centre of gravity, not the feature matrix.
The decision tree
Ask about the part that will still be hard in six months, not the demo, and answer every question instead of stopping at the first yes. Two yeses is common and fine; the combined stack is in step 08. Three yeses usually means one system doing three jobs that could be split.
When each earns its place
| Layer | Best when | Overkill |
|---|---|---|
| LlamaIndex | the documents are messy and plentiful | your “corpus” is one table or an API |
| LangChain | providers and stores are unsettled, or you want a standard agent | one model, one store, one path |
| LangGraph | the path branches, loops or needs a gate | the flow is a straight line |
The model underneath is a separate choice. Any of the three can call Claude; the newest Claude models reject sampling parameters such as temperature, so check that an integration does not send them (langchain-anthropic does not by default).
“Chat over 40,000 PDFs”: LlamaIndex
from llama_index.core import SimpleDirectoryReader, VectorStoreIndex
from llama_index.core.node_parser import SentenceSplitter
documents = SimpleDirectoryReader("docs_corpus").load_data()
index = VectorStoreIndex.from_documents(
documents,
transformations=[SentenceSplitter(chunk_size=512, chunk_overlap=64)],
)
index.storage_context.persist("index_store") # pay for ingestion once
retriever = index.as_retriever(similarity_top_k=6)
for hit in retriever.retrieve("Who approves a refund over $50?"):
print(hit.score, hit.node.metadata["file_name"])
LlamaIndex 0.14. Set Settings.embed_model first; the default embedding model is OpenAI’s.
The control flow is three steps (retrieve, answer, cite) and nothing branches. What is hard is that a third of the PDFs are scans, the useful content sits in tables, and the right chunk boundary is not the paragraph. Your time goes into document processing, chunking and an eval set. A graph would add a state schema to a one-path problem.
“A refund agent that needs approval”: LangGraph
from langchain.agents import create_agent
from langchain.agents.middleware import HumanInTheLoopMiddleware
from langgraph.checkpoint.memory import InMemorySaver
def get_order(order_id: str) -> str:
"""Look up an order's status and amount by id."""
return orders.lookup(order_id)
def issue_refund(order_id: str, amount_usd: int) -> str:
"""Refund an order. Irreversible."""
return payments.refund(order_id, amount_usd)
agent = create_agent(
"anthropic:claude-sonnet-5-5",
tools=[get_order, issue_refund],
system_prompt="You handle refund requests for orders.",
middleware=[HumanInTheLoopMiddleware(interrupt_on={"issue_refund": True})],
checkpointer=InMemorySaver(),
)
type(agent).__name__ # 'CompiledStateGraph': a LangGraph graph
Some paths need a lookup, refunds need a person, and a crash must not refund twice. If the shape is “a tool loop, plus a pause before one tool”, create_agent with human-in-the-loop middleware is enough, and it is already a LangGraph graph. When the topology is yours (parallel checks, a threshold, a capped retry), write the StateGraph directly, as in graph engineering and Checkpointers, Threads & Store.
“Classify, summarise, post to Slack”: no framework
import anthropic
client = anthropic.Anthropic()
def ask(prompt: str) -> str:
resp = client.messages.create(
model="claude-haiku-5-5", max_tokens=1024,
messages=[{"role": "user", "content": prompt}])
if resp.stop_reason != "end_turn":
raise RuntimeError(f"stopped: {resp.stop_reason}")
return "".join(b.text for b in resp.content if b.type == "text")
ticket = fetch(ticket_id)
category = ask(f"Reply with one word: billing, bug or other.\n\n{ticket}").strip()
summary = ask(f"Summarise this ticket in two sentences.\n\n{ticket}")
slack.post(channel=ROUTE.get(category, "#support"), text=summary)
Three calls in a straight line, one file, nothing to persist and nothing to decide. A framework would not shorten this, and it would lengthen every stack trace. The test: if you can write the flow as a numbered list and no number says “go back to step 2” or “wait for a person”, you do not have an orchestration problem yet. How the bare loop works is in The Agent Loop.
How they combine in production
from typing import TypedDict
import anthropic
from langgraph.graph import StateGraph, START, END
from llama_index.core import StorageContext, load_index_from_storage
store = StorageContext.from_defaults(persist_dir="index_store")
retriever = load_index_from_storage(store).as_retriever(similarity_top_k=6)
client = anthropic.Anthropic()
class State(TypedDict):
question: str
chunks: list[str]
answer: str
def retrieve(state: State) -> dict: # data layer: one node
hits = retriever.retrieve(state["question"])
return {"chunks": [h.get_content() for h in hits if (h.score or 0) > 0.3]}
def answer(state: State) -> dict: # provider SDK
prompt = "\n\n".join(state["chunks"] + [state["question"]])
resp = client.messages.create(model="claude-sonnet-5-5", max_tokens=2048,
messages=[{"role": "user", "content": prompt}])
return {"answer": "".join(b.text for b in resp.content if b.type == "text")}
builder = StateGraph(State) # control layer
builder.add_node("retrieve", retrieve)
builder.add_node("answer", answer)
builder.add_node("escalate", lambda s: {"answer": "Routed to a person."})
builder.add_edge(START, "retrieve")
builder.add_conditional_edges("retrieve", lambda s: "answer" if s["chunks"] else "escalate")
graph = builder.compile() # answer and escalate end the run
The common production shape picks no winner: LlamaIndex owns retrieval and appears upstairs as exactly one node, LangGraph owns what runs next, and the provider SDK makes the call. Swapping the retriever for SQL, or adding a reranker, changes one function. The graph never knew how retrieval worked, which is the property to design for.
The abstraction tax, and the rip-out cost
| Layer | You own | To rip out |
|---|---|---|
| LangChain | wiring between components | rewrite the wiring |
| LlamaIndex | a processed, embedded corpus | re-ingest, re-index, re-run evals |
| LangGraph | a graph shape and its checkpoints | the shape survives; the API does not |
Before adopting any of them, check five things. Can you print the exact prompt that was sent? Can you see the state between steps? What happens on a crash mid-run? Can you test one step alone? What is the rip-out cost in month nine? A framework that hides the prompt hides the thing you tune most: what is in the window.
Following a 2024 tutorial (LLMChain, initialize_agent) on LangChain 1.x. Assuming LangGraph means LangChain. Adopting all three for a three-call pipeline. Passing temperature through an integration to a model that rejects it.
“When would you not use an agent framework and write the loop yourself?” Answer with the layers, then the rip-out costs, then one system where you used one layer and skipped the others.
A team says “we use LangGraph, so we will not touch LangChain.” Then they call create_agent. What did they adopt?
Both. In LangChain 1.x, create_agent returns a compiled LangGraph graph, and the langchain package depends on langgraph. The reverse is not true: a StateGraph whose nodes call a provider SDK needs no LangChain chain, retriever or agent.
You are nine months in and want to drop LlamaIndex. What costs the most to replace?
Not the code: the processed corpus. Parsing, chunking, metadata and embeddings were paid for once and encoded in LlamaIndex’s node format. Wiring is cheap to rewrite; a re-ingestion and re-index of the corpus, plus re-running the retrieval evals, is not.
Your flow is classify, summarise, post to Slack. A colleague proposes LangGraph “for observability”. What do you say?
Three calls in a straight line have no branch, no wait and no state to resume. Log the request and the usage of each call and you have the observability. Add a graph the day a step must go back, wait for a person or survive a crash.
- LlamaIndex is the data layer, LangChain the integration layer, LangGraph the control layer.
- Since 1.0, LangChain’s
create_agentruns on LangGraph; legacy chains live inlangchain-classic. - Adopt the layer where the problem is hard; a straight-line flow needs none of them.
- The common production stack: LlamaIndex retrieval as one LangGraph node, provider SDK underneath.
- Wiring is cheap to rewrite; a processed corpus is not.