Short answer: LangChain gives you high-level building blocks and a ready-made agent. LangGraph is the low-level orchestration runtime for stateful, controllable workflows. LangChain's agent runs on LangGraph under the hood.
Let's see the difference in code.
LangChain: a tool-using agent in a few lines
from langchain.agents import create_agent
from langchain.tools import tool
@tool
def get_policy_limit(policy_id: str) -> str:
"""Return the claim limit for a policy."""
return "Limit for " + policy_id + " is ₹5,00,000"
agent = create_agent(
model="openai:gpt-4.1-mini",
tools=[get_policy_limit],
system_prompt="You are a helpful insurance assistant.",
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "What is the limit on policy P-1029?"}]}
)
print(result["messages"][-1].content)
The model decides which tools to call and when to stop. Perfect for assistants and simple tool use.
LangGraph: you control every step
Now a claims workflow: classify the claim, route it, and pause for human approval on large amounts.
from typing import TypedDict
from langgraph.graph import StateGraph, START, END
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.types import interrupt, Command
class ClaimState(TypedDict):
claim_text: str
amount: float
approved: bool
def assess(state: ClaimState):
# call an LLM or a decision model here to extract the amount
return {"amount": 75000.0}
def route(state: ClaimState) -> str:
return "human_review" if state["amount"] > 50000 else "auto_approve"
def human_review(state: ClaimState):
decision = interrupt({"question": "Approve this claim?", "amount": state["amount"]})
return {"approved": decision == "yes"}
def auto_approve(state: ClaimState):
return {"approved": True}
builder = StateGraph(ClaimState)
builder.add_node("assess", assess)
builder.add_node("human_review", human_review)
builder.add_node("auto_approve", auto_approve)
builder.add_edge(START, "assess")
builder.add_conditional_edges("assess", route, ["human_review", "auto_approve"])
builder.add_edge("human_review", END)
builder.add_edge("auto_approve", END)
graph = builder.compile(checkpointer=InMemorySaver())
config = {"configurable": {"thread_id": "claim-42"}}
graph.invoke({"claim_text": "Hospital bill..."}, config) # pauses at human_review
graph.invoke(Command(resume="yes"), config) # resumes after approval
In production, swap InMemorySaver for a Postgres checkpointer so the workflow survives restarts.
Side by side
| LangChain | LangGraph | |
|---|---|---|
| Level | High-level components and agent | Low-level orchestration runtime |
| Control flow | Model decides (agent loop) | You define nodes, edges, branches, loops |
| State | Messages | Any typed state you design |
| Durability | Via LangGraph underneath | Built-in checkpointers |
| Human-in-the-loop | Via middleware |
interrupt() anywhere in the graph |
| Best for | Assistants, RAG chains, simple tool use | Business workflows, multi-agent systems, long-running jobs |
Which should you learn first?
LangChain first: models, prompts, structured output, tools. Then LangGraph, because every serious agentic system you build will need state and control.
That is exactly the order in Vector 2.0, the live Gen-AI developer cohort by TechSimPlus and Prateek Mishra: Sprint 1 covers LangChain, Sprint 3 covers LangGraph with ClaimSense, and Sprint 4 adds multi-agent systems with MCP and A2A.
Check the Complete Content: vector.techsimplus.com
Top comments (0)