Agent Official source

LangGraph

A low-level orchestration framework for long-running, stateful, and resilient agents.

Quick start

pip install -U langgraph

What it does

LangGraph models agent behavior as a graph with explicit state and transitions. It is designed for workflows that need persistence, streaming, branching, human checkpoints, or recovery across long-running execution.

Best for

  • Stateful agents with non-linear control flow
  • Durable workflows that pause and resume
  • Systems that need human review at defined checkpoints

Before you use it

The low-level graph model offers control but adds design work. Define state ownership, idempotency, error recovery, and observability before expanding a prototype into a production workflow.

How the graph model helps

Nodes perform work and edges determine what can happen next. State carries the data that later nodes need. By making those transitions explicit, LangGraph can represent loops, conditional branches, specialist subgraphs, human review points, and resumable execution without hiding the control flow inside a long agent prompt.

The same flexibility introduces responsibility. Define a typed state schema and make it clear which node owns each field. Store references rather than large duplicated payloads when possible. A node that may run again after a timeout should be idempotent or able to detect prior completion. External side effects need stable operation identifiers so recovery does not send the same message or create the same record twice.

Persistence and human review

Checkpointing is valuable when a workflow can pause, wait for approval, or recover after process failure. Choose a persistence backend whose durability and data policy match the application. Decide how long checkpoints live, how sensitive state is encrypted or redacted, and how a schema migration affects runs created by an earlier version.

Place human review before irreversible actions, not after them. The review screen should show the proposed action, relevant source data, model output, and the exact continuation path. Test approval, rejection, edit, timeout, and duplicate-resume cases. A visible pause button alone is not a safety design unless the transition semantics are deterministic.

When the overhead is justified

LangGraph is a strong fit when the workflow truly needs long-lived state, branching, cycles, recovery, streaming, or multiple review checkpoints. It can be excessive for a short request/tool/response loop. In that case, the OpenAI Agents SDK or plain application code may reach production with less operational surface. Prototype one representative graph and measure recovery behavior as carefully as its happy path before committing the architecture.