~/ai_assets_directory_
AI Workflow verified · tested by us 41.3k stars
langgraph.workflow

LangGraph

Low-level Python framework from LangChain for building stateful, long-running AI agents with durable execution, human-in-the-loop control and persistent memory.

Overview

LangGraph is a low-level orchestration framework for building, managing and deploying long-running, stateful agents, used in production by companies like Klarna, Replit and Elastic. Unlike opinionated agent frameworks, it gives you graph primitives (nodes, edges, state) and lets you build your own abstraction on top. It can be used standalone, without LangChain.

How it works

Agents get durable execution: they persist through failures and resume exactly where they left off on long-running tasks. You can also inspect or modify agent state at any point during execution before it continues (human-in-the-loop), and memory covers both short-term working state for a single run and long-term memory that persists across sessions. For debugging, LangSmith traces execution paths, captures state transitions and reports runtime metrics. If you want planning, subagents or file-system access without building the graph primitives yourself, pair LangGraph with Deep Agents, a higher-level package built on top of it.

Examples

  • A durable customer-support agent that survives a process restart mid-task and resumes from its last checkpoint.
  • Adding a human-approval step inside an agent's execution graph before a high-stakes action runs.
  • Building a custom multi-agent architecture from scratch when CrewAI's higher-level Crew/Flow abstraction is too opinionated for the use case.

Installation

You need Python 3.9+ and an API key for whichever LLM provider you plan to use. LangGraph itself doesn't ship a model.

  1. Install the package, ideally inside a virtual environment:
    pip install -U langgraph
    
  2. Install the LangChain integration for your model provider, for example:
    pip install langchain-openai
    
  3. Set your provider's API key as an environment variable, for example OPENAI_API_KEY.
  4. Define your graph in Python (nodes, edges and state) and run it as a script.
  5. Optional: set LANGCHAIN_TRACING_V2=true and LANGCHAIN_API_KEY to inspect execution traces in LangSmith.

Related assets