langgraph

Construa fluxos de trabalho de agente duráveis e com estado usando LangGraph. Use quando precisar de fluxo de controle personalizado baseado em grafo, intervenção humana, persistência ou multiagente…

npx skills add https://github.com/langchain-ai/docs --skill langgraph

LangGraph

LangGraph is a low-level orchestration framework and runtime for building, managing, and deploying long-running, stateful agents. It provides durable execution, streaming, human-in-the-loop interactions, and time-travel debugging.

When to use

Use LangGraph when you need to:

  • Design custom agent workflows with explicit graph-based control flow
  • Add durable execution so agents survive failures and restarts
  • Implement human-in-the-loop with interrupts and approval steps
  • Build multi-agent systems with state shared across agents
  • Stream intermediate results from long-running agent tasks
  • Time-travel debug by replaying agent execution from any checkpoint

When NOT to use

  • For a simple tool-calling agent, use LangChain agents instead—less boilerplate for common patterns
  • For a batteries-included agent with planning and subagents, use Deep Agents instead
  • LangGraph is the orchestration layer—use it when you need fine-grained control over agent behavior

Install

# Python
pip install -U langgraph

# JavaScript/TypeScript
npm install @langchain/langgraph @langchain/core

Quick reference

Graph API (recommended for most use cases)

from langgraph.graph import StateGraph, MessagesState, START, END

def my_node(state: MessagesState):
    return {"messages": [{"role": "ai", "content": "hello world"}]}

graph = StateGraph(MessagesState)
graph.add_node(my_node)
graph.add_edge(START, "my_node")
graph.add_edge("my_node", END)
graph = graph.compile()

result = graph.invoke(
    {"messages": [{"role": "user", "content": "Hello!"}]}
)

Functional API (for simple pipelines)

from langgraph.func import entrypoint, task

@task
def step_one(input: str) -> str:
    return f"processed: {input}"

@entrypoint()
def pipeline(input: str) -> str:
    return step_one(input).result()

Add human-in-the-loop

from langgraph.types import interrupt

def human_approval(state: MessagesState):
    answer = interrupt({"question": "Approve this action?"})
    return {"messages": [{"role": "user", "content": answer}]}

Key concepts

ConceptDescription
StateGraphDefine nodes and edges that form your agent's control flow
MessagesStateBuilt-in state schema for chat-based agents
compile()Compile a graph builder into an executable graph
interrupt()Pause execution and wait for human input
CheckpointerPersist state for durable execution and time-travel
Graph API vs Functional APIGraph API for complex workflows; Functional API for linear pipelines

Key documentation

API reference

For SDK class and method details, use the LangChain API Reference site:

  • Browse: https://reference.langchain.com/python/langgraph
  • MCP server: https://reference.langchain.com/mcp

Related skills

  • langchain—Core building blocks for models, tools, and simple agents
  • deep-agents—High-level agent harness built on LangGraph
  • langsmith—Trace, evaluate, and deploy your LangGraph agents

Mais skills de langchain-ai

deepagents-thread-inspector
langchain-ai
Inspecione e explique conversas no armazenamento de sessões SQLite local do Deep Agents Code. Use como fallback quando a ferramenta de rastreamento LangSmith não estiver disponível, para…
deepagents-python-quickstart
langchain-ai
Estruture um Deep Agent local mínimo em Python seguindo o quickstart oficial, usando busca web nativa do provedor em vez de Tavily. Use quando o usuário quiser…
deepagents-typescript-quickstart
langchain-ai
Estruture um Deep Agent local mínimo em TypeScript seguindo o quickstart oficial, usando busca web nativa do provedor em vez de Tavily. Use quando o usuário…
eval-engineering
langchain-ai
Inspecione iterativamente um repositório de agente e traces opcionais fornecidos pelo usuário, entreviste o usuário e crie, execute e audite evals do Harbor um por vez. Use para…
LangChain RAG Pipeline
langchain-ai
INVOQUE ESTA HABILIDADE ao construir QUALQUER sistema de geração aumentada por recuperação (RAG). Abrange carregadores de documentos, RecursiveCharacterTextSplitter, embeddings (OpenAI),…
LangChain Structured Output & HITL
langchain-ai
langchain-structured-output-&-hitl — uma skill instalável para agentes de IA, publicada por langchain-ai/langchain-skills.
LangSmith Datasets
langchain-ai
INVOQUE ESTA HABILIDADE ao criar conjuntos de dados de avaliação a partir de rastreamento OU ao fazer upload de conjuntos de dados para o LangSmith OU ao consultar conjuntos de dados. Abrange tipos de conjuntos de dados (final_response,…
langsmith-evaluator
langchain-ai
INVOQUE ESTA HABILIDADE ao construir pipelines de avaliação para LangSmith. Abrange três componentes principais: (1) Criação de Avaliadores - LLM como Juiz, código personalizado; (2)…