DEV Community

Cover image for LangChain vs LangGraph: Which Should You Use?
George K.
George K.

Posted on Originally published at barcelonacodeschool.com

LangChain vs LangGraph: Which Should You Use?

AI framework comparison

They belong to the same ecosystem and solve different layers of the problem. Start at the highest abstraction that gives your team enough control.

Published 13 October 2026 · Barcelona Code School

Choose LangChain when you want a configurable, higher-level agent harness with models, tools, prompts and middleware.

Choose LangGraph directly when the orchestration itself is your application: custom state, deterministic branches, durable execution, interrupts or long-running workflows. LangChain agents already run on LangGraph, so this is usually a choice of abstraction level—not two unrelated technologies.

Key takeaways

  • LangChain is the higher-level agent framework; LangGraph is the low-level orchestration runtime.
  • LangChain agents inherit LangGraph capabilities underneath.
  • Direct LangGraph gives more explicit control but more engineering responsibility.
  • Neither replaces application authorization, safe side effects or testing.
  • Start high-level and move down only for a named control requirement.

What is the real difference?

Current LangChain documentation describes create_agent as a configurable harness around a model loop: model, tools, prompt and middleware. It is intended to get a standard agent running with less orchestration code while still allowing policies, retries and routing through middleware.

LangGraph is the lower-level framework and runtime for long-running, stateful agents. Developers define shared state, nodes and transitions, mixing deterministic code with model-driven decisions. LangGraph can be used without LangChain, although LangChain integrations are commonly used for models and tools.

Figure 1. Two entry points into the same agent stack

Start with LangChain

  • Model · Tools · Prompt · Middleware

Use the prebuilt agent loop and customise the harness.

Built on LangGraph

Use LangGraph directly

  • Typed state · Nodes · Edges · Checkpoints · Interrupts

Define the orchestration, transitions and recovery semantics yourself.

The decision is how much of the orchestration you need to own explicitly.

Text equivalent: LangChain offers a high-level agent harness that combines a model, tools, prompt and middleware and uses LangGraph underneath. Direct LangGraph exposes state, graph nodes, edges, persisted checkpoints and interrupts so developers can implement custom orchestration.

LangChain vs LangGraph side by side

Criterion LangChain Direct LangGraph
Primary abstraction Configurable agent harness State graph and orchestration runtime
Best starting fit Standard model-and-tools agent loop Custom stateful or long-running workflow
Control surface Prompts, tools and middleware State, nodes, edges, commands and interrupts
State Agent state managed through the harness Explicit schema and update rules
Routing Prebuilt loop plus middleware/customisation Developer-defined deterministic and agentic transitions
Human review Available through agent middleware/runtime capabilities Dynamic interrupts with persisted state and resume input
Code burden Lower for common agent architectures Higher because orchestration is application code
Typical risk Forcing a complex process into a convenient default loop Building custom graph machinery before it is needed

When should you start with LangChain?

Use LangChain when the core pattern is familiar: the model reads messages, chooses among bounded tools and returns an answer. The harness is especially useful when you want provider integrations and middleware without designing every state transition first.

  • Your first version is a conventional tool-calling agent.
  • Prompt, tool and middleware customisation is enough.
  • You want to validate the use case before owning graph internals.
  • The team benefits from less orchestration code.

4-week live bootcamp · Barcelona or online

Go from one workflow to a complete AI automation system

In the AI Agent & Automation Bootcamp you build a no-code Virtual AI Department with n8n, RAG, connected agents and human approvals — live with an instructor and a small group.

See the bootcamp programme →

Not sure it fits? Take the free AI Career Roadmap test

When should you use LangGraph directly?

Use LangGraph directly when control flow is product logic. Good signals include long-running state, deterministic stages around agent decisions, conditional review points, nested workflows or recovery that must resume from a known checkpoint.

Interrupts can persist state and wait for external input. They require a checkpointer and stable thread ID. Because an interrupted node restarts from its beginning on resume, code before the interrupt must not create an unguarded side effect.

  • The state schema and transitions require explicit review.
  • Deterministic and model-driven nodes must interleave.
  • The workflow pauses and resumes across time or people.
  • Custom routing is clearer as a graph than middleware around a loop.

Do not choose LangGraph because the workflow sounds sophisticated. Choose it when you can name the state or control behavior the higher-level harness cannot express clearly.

How do you choose in six steps?

  1. Define the transaction. Name the input, final output, tools, owner and success condition.
  2. Draw the smallest agent loop. If model → tool → model is enough, prototype it with LangChain.
  3. List required state transitions. Identify checkpoints, deterministic branches, pauses and resume rules.
  4. Mark side effects and approvals. Put authorization and human review before consequential tools.
  5. Prototype the hardest control. Test the interrupt, custom route or recovery path that motivates direct LangGraph.
  6. Choose the highest sufficient abstraction. Keep LangChain if it stays clear; use LangGraph directly only where explicit orchestration reduces risk.

Permissions, failure paths and human approval

Risk Required control Pass condition
Tool has broad access Scoped service identity and allowlisted operation Agent cannot widen its own permission
Human review pause Persist state, authenticate reviewer, record decision Resume uses the right thread and authorised input
Side effect before interrupt Move write after approval or make it idempotent Resume does not repeat the write
Transient tool failure Bounded retry and preserved evidence Stops or escalates after the limit
Unknown external state Read destination before replay No blind duplicate action
Untrusted prompt content Fixed tools, schema validation and policy outside prompt Content cannot change authority

Test the architecture before committing

Test Pass condition
Normal request Correct result with traceable tool evidence
Malformed tool input Validation or safe correction; no write
Approval rejected Consequential action remains unexecuted
Pause and resume Correct state resumes under the same thread
Duplicate resume No repeated external side effect
Tool timeout Bounded recovery retains context
Unauthorised request No data or tool access
Owner handover Second developer explains and diagnoses the path

Success criteria

  • The selected abstraction expresses the workflow without duplicate control layers.
  • State and external writes have explicit contracts.
  • Review and resume behavior is tested, including duplicate delivery.
  • Permissions remain outside model discretion.
  • Failures preserve enough evidence for diagnosis.
  • The team can maintain the design without one hidden expert.

Choose the learning path that matches the stack

If you want to engineer a custom Python or JavaScript agent product, study LangChain, LangGraph and software delivery directly. Barcelona Code School's current AI Agent & Automation Bootcamp instead teaches visual business systems with n8n, data, RAG, approvals, testing and recovery.

The bootcamp is relevant when your goal is applied no-code automation, not as a substitute for a code-first LangGraph course.

Compare BCS AI learning paths

Frequently asked questions

Is LangGraph part of LangChain?

LangGraph is developed by LangChain Inc and LangChain agents are built on LangGraph, but LangGraph is a separate low-level orchestration framework and can be used without LangChain.

Should beginners use LangChain or LangGraph?

Start with LangChain when a standard tool-calling agent and configurable middleware meet the need. Use LangGraph directly after you can describe why custom state, routing, persistence or interruption behavior must be controlled at graph level.

Can LangChain and LangGraph be used together?

Yes. LangChain components and agents use LangGraph capabilities, and a custom LangGraph workflow can use LangChain model and tool integrations. The choice is mainly whether you work through the higher-level harness or define orchestration directly.

When should I move from LangChain to LangGraph?

Move to direct LangGraph orchestration when the default agent loop no longer expresses your required state transitions, deterministic branches, long-running checkpoints, review points or recovery behavior clearly.

Does LangGraph make an agent safe by itself?

No. Persistence and interrupts provide control points, but the application must still enforce authentication, authorization, tool permissions, input validation, idempotency, audit evidence and safe handling of external writes.

Sources

  1. LangChain overview.
  2. LangChain agents.
  3. LangGraph overview.
  4. LangGraph interrupts.
  5. Thinking in LangGraph.
  6. BCS: How to Build an AI Agent.
  7. Barcelona Code School AI courses.

Continue learning

Design the agent before choosing a framework

Compare BCS AI courses

Build visual AI automation systems with n8n


Originally published at Barcelona Code School. Learn more about our AI, coding and design programmes at barcelonacodeschool.com.

Top comments (0)