Barcelona Code School

Since 2015 / 500+ graduates

LangChain vs LangGraph: Which Should You Use?

AI framework comparison

LangChain vs LangGraph: Which Should You Use?

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

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

CriterionLangChainDirect LangGraph
Primary abstractionConfigurable agent harnessState graph and orchestration runtime
Best starting fitStandard model-and-tools agent loopCustom stateful or long-running workflow
Control surfacePrompts, tools and middlewareState, nodes, edges, commands and interrupts
StateAgent state managed through the harnessExplicit schema and update rules
RoutingPrebuilt loop plus middleware/customisationDeveloper-defined deterministic and agentic transitions
Human reviewAvailable through agent middleware/runtime capabilitiesDynamic interrupts with persisted state and resume input
Code burdenLower for common agent architecturesHigher because orchestration is application code
Typical riskForcing a complex process into a convenient default loopBuilding 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.

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

RiskRequired controlPass condition
Tool has broad accessScoped service identity and allowlisted operationAgent cannot widen its own permission
Human review pausePersist state, authenticate reviewer, record decisionResume uses the right thread and authorised input
Side effect before interruptMove write after approval or make it idempotentResume does not repeat the write
Transient tool failureBounded retry and preserved evidenceStops or escalates after the limit
Unknown external stateRead destination before replayNo blind duplicate action
Untrusted prompt contentFixed tools, schema validation and policy outside promptContent cannot change authority

Test the architecture before committing

TestPass condition
Normal requestCorrect result with traceable tool evidence
Malformed tool inputValidation or safe correction; no write
Approval rejectedConsequential action remains unexecuted
Pause and resumeCorrect state resumes under the same thread
Duplicate resumeNo repeated external side effect
Tool timeoutBounded recovery retains context
Unauthorised requestNo data or tool access
Owner handoverSecond 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.
Back to posts