ARTICLE

LangChain & LangGraph

Updated 2 May 2025
agentsframeworkslangchainlanggraphorchestrationpythontypescript

LangChain & LangGraph

LangChain is the most widely used AI application framework. If you’ve built anything with LLMs beyond a simple API call, you’ve probably encountered it — or something inspired by it.

But LangChain the library and LangGraph the agent engine are different things, and the distinction matters. LangChain gives you building blocks. LangGraph gives you control over how agents think and act.


LangChain — The Building Blocks

LangChain provides abstractions for the common things AI applications do:

ComponentWhat It DoesExample
Chat modelsUnified interface to any LLMTalk to OpenAI, Anthropic, Gemini, local models — same code
PromptsTemplate and manage promptsSystem prompts, few-shot examples, dynamic injection
Output parsersStructure LLM outputExtract JSON, lists, structured data from freeform text
RetrieversFetch relevant dataVector search, database queries, web search
ToolsGive LLMs actionsWeb search, code execution, API calls, file operations
ChainsCompose operationsRetrieve → prompt → generate → parse → store

Available in: Python and TypeScript/JavaScript

The honest assessment: LangChain was criticised in 2023-2024 for being over-abstracted — too many layers between you and the LLM. The team responded. Recent versions are much cleaner. But if you’re doing something simple, you might not need it at all. The native APIs from Anthropic or OpenAI are excellent for basic tool use.


LangGraph — The Agent Engine

LangGraph is where the interesting work happens. It’s a framework for building stateful, controllable agent workflows using a graph-based architecture.

flowchart TD
    Start([User Input]) --> Router{Route}
    Router -->|Simple| Direct[Direct Response]
    Router -->|Needs Research| Research[Research Node]
    Router -->|Needs Code| Code[Code Node]
    Research --> Evaluate{Good Enough?}
    Code --> Evaluate
    Evaluate -->|No| Research
    Evaluate -->|Yes| Respond[Generate Response]
    Direct --> End([Output])
    Respond --> End

Why Graphs?

An agent’s workflow isn’t linear. It branches, loops, backtracks, and makes decisions. A graph is the natural data structure:

  • Nodes = actions (call the LLM, execute a tool, check a condition)
  • Edges = transitions (what happens next, based on what just happened)
  • State = persistent memory across the graph (what has the agent learned so far?)

You define the graph. LangGraph executes it. The LLM makes decisions at each node. You control the structure.

Key Features

FeatureWhy It Matters
State managementThe agent remembers what it’s done. Persists across turns.
Human-in-the-loopPause at any node for human approval before proceeding
CheckpointingSave and resume agent state. Crucial for long-running tasks.
StreamingSee what the agent is doing in real time
Multi-agentMultiple agents collaborating in the same graph
SubgraphsCompose complex workflows from smaller, reusable workflows

When LangGraph Shines

  • Complex research tasks that require multiple search → evaluate → refine cycles
  • Multi-step workflows where the order depends on intermediate results
  • Any task requiring human approval gates
  • Production agent systems that need observability and debugging

LangSmith — Observability

You can’t debug what you can’t see. LangSmith is the companion observability platform:

  • Trace every step — See exactly what the LLM received, what it returned, what tool was called
  • Evaluate quality — Run test datasets through your agent, measure performance
  • Debug failures — When an agent goes wrong, trace backwards to find where
  • Monitor production — Latency, cost, error rates, quality metrics

This is the part people underestimate. Building an agent is one thing. Knowing why it failed on a Tuesday at 3am is another.


Comparison with Alternatives

AspectLangGraphCrewAINative API (Anthropic, OpenAI)
ControlMaximum — you define every node and edgeModerate — role-based, framework decides flowBasic — single-agent loop
Multi-agentYes, explicit graph connectionsYes, role-based delegationNo (must build yourself)
Learning curveSteepModerateGentle
Best forComplex, production workflowsQuick multi-agent prototypesSimple tool use, single agent
ObservabilityLangSmith (excellent)Limited built-inRoll your own

What I’m Still Learning

  • The right level of graph complexity — too few nodes and you lose control, too many and it’s brittle
  • When to use LangGraph vs just calling the API directly (the 80/20 rule: most tasks don’t need a graph)
  • How LangGraph interacts with MCP — the integration is still maturing

Go Deeper

Sources

enes