1:1 mentoring with Big Tech AI engineers

LangChain vs LlamaIndex vs LangGraph — Which One, and When

Three names, two from the same company, and a choice most teams make by vibes. They are three layers of one stack, and since LangChain 1.0 two of them share a runtime.

By AgenticPrep TeamUpdated 9 min read
Key idea

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.

Three layers of one stack: pick the one that owns your hard problem
THREE JOBS, NOT THREE RIVALSLlamaIndex 0.14data layerparse, chunk, embedindex, retrieve, rerankLangChain 1.4integration layerchat models, tools, storescreate_agent + middlewareLangGraph 1.2control layerstate, nodes, edgescheckpoints, interruptscreate_agent runs on LangGraphProvider SDK + your database + ordinary codeenough on its own for a large share of shipped LLM softwareAdopt the layer where your problem is hard. Leave the others out.

“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

1.4LangChain, on the 1.x line since October 2025
1.2LangGraph, 1.x with no breaking changes promised before 2.0
0.14LlamaIndex core, still on 0.x

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

LlamaIndex data
  • connectors, parsing, chunking, index types
  • retrievers, postprocessors, query engines
  • defaults chosen by people staring at messy PDFs
LangChain integrations
  • one interface over many models, stores and tools
  • create_agent: a standard tool loop in a few lines
  • best while components are still changing
LangGraph control
  • 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 what the hard part is; the framework falls out of the answer
ASK ABOUT THE PART THAT IS HARD IN SIX MONTHSIs the hard part a large, messy corpus?scans, tables, 40,000 PDFsLlamaIndexingestion and retrievalyesnoDoes the flow branch, retry or wait for a person?gates, loops, resume after a crashLangGrapha graph you can audityesnoDo you want a standard agent, or many providers?one tool loop, swappable componentsLangChaincreate_agent + integrationsyesnoNo frameworkprovider SDK and a few functionsAnswer all three. Two yeses is normal: LlamaIndex retrieval inside a LangGraph node.

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

LayerBest whenOverkill
LlamaIndexthe documents are messy and plentifulyour “corpus” is one table or an API
LangChainproviders and stores are unsettled, or you want a standard agentone model, one store, one path
LangGraphthe path branches, loops or needs a gatethe 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

LayerYou ownTo rip out
LangChainwiring between componentsrewrite the wiring
LlamaIndexa processed, embedded corpusre-ingest, re-index, re-run evals
LangGrapha graph shape and its checkpointsthe 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.

Common mistakes

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.

Interview angle

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

Check yourself
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.

Recap
  • LlamaIndex is the data layer, LangChain the integration layer, LangGraph the control layer.
  • Since 1.0, LangChain’s create_agent runs on LangGraph; legacy chains live in langchain-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.

Next: Why a Graph? State, Nodes & Edges — the LangGraph course, from the first node to production.

  • langchain
  • llamaindex
  • langgraph
  • frameworks
  • agents
Share

Keep reading

All posts

Enjoyed this post? The full curriculum has 151 sections, system design problems, and AI-reviewed practice runs.

See the full guide