Skip to main content
LangGraph provides a flexible framework for building stateful, multi-actor applications with LLMs. This guide walks through the core concepts of building graphs.

Core Concepts

A LangGraph workflow consists of:
  • State: The data structure that flows through your graph
  • Nodes: Functions that process the state
  • Edges: Connections between nodes that define the flow
  • Graph: The compiled workflow that orchestrates execution

Creating a Simple Graph

Conditional Edges

Use conditional edges to create dynamic routing based on state:

Working with Tools

Integrate tools using the prebuilt ToolNode:

State Reducers

Use Annotated types to define how state updates are merged:
The add_messages reducer intelligently merges message lists:
  • Appends new messages by default
  • Updates existing messages by ID
  • Handles message deletion with RemoveMessage

Multi-Agent Patterns

Create graphs with multiple agents by adding nodes for each agent:

Best Practices

  • Keep nodes focused: Each node should handle a single responsibility
  • Use type hints: Define clear state schemas for better IDE support
  • Test incrementally: Build and test your graph one node at a time
  • Visualize your graph: Use graph.compile().get_graph().print_ascii() to debug
  • Handle errors gracefully: Add error handling in your node functions

Next Steps