Beginner

Basics of LangGraph Workflows

langgraph · workflows · ai · agents · orchestration · artificial · intelligence · generative · errors · studio · workflow · pydantic · functions · memory · node · version · basic.py · bas...

Level: Beginner/Intermediate Technology: Python 3.11+, LangGraph, LangGraph CLI, LangGraph Studio


Table of Contents


1. Create your first LangGraph workflow


1.1 — AI workflows

Two main categories of workflows

There are two main types of workflows that can be built with LangGraph. The terms used to describe them will likely evolve over time, so it’s best to focus on the underlying concepts.

First type — AI agents (automation of known tasks)

Some workflows automate tasks whose potential path and decision points are known in advance. We can therefore map what needs to be automated. Today we call this an AI agent. What makes AI agents more useful and capable are large language models (LLMs), which help the agent analyze and generate data.

Second type — Agentic AI (autonomous reasoning on steps)

Other workflows take a high-level query and themselves determine the steps needed to accomplish that query. These workflows use LLMs to break the query into tasks and determine when it is complete. One key difference: He is not told in advance the exact steps to follow. We can provide some general tools available, but the system itself determines which tools to use, in what order, and how many iterations are needed to complete the task. Today we call this Agentic AI.

LangGraph Overview

LangGraph is a framework that helps manage the entire lifecycle of any AI workflow, from writing and debugging to deployment and monitoring. It uses a graph model of nodes and edges to represent workflows in your application.

  • Nodes: Perform an action, such as calling an LLM or executing a function.
  • Edges: are the possible routes between the nodes.
graph TD
    START([__start__]) --> node1[Node A\nAppel LLM / Fonction]
    node1 -->|edge| node2[Node B]
    node1 -->|conditional edge| node3[Node C]
    node2 --> END([__end__])
    node3 --> END([__end__])

What this training covers

In this training, we will:

  1. Create a LangGraph application with a basic workflow.
  2. Install the LangGraph CLI, which allows you to run the application locally.
  3. Use LangGraph Studio for debugging and monitoring — a web interface to view the graph, set breakpoints before and after nodes, modify data, and restart the application from specific nodes.

Prerequisites: Python and Pip must be installed in their minimum required version.


1.2 — Setting up the environment

LangGraph CLI

The LangGraph CLI allows you to run LangGraph applications on your local machine. It has an extra inmem which enables hot reloading of code changes, allowing them to be tested without restarting the application.

Installation

# Vérifier la version minimale de Python requise
python --version

# Créer un environnement virtuel
python -m venv .venv

# Activer l'environnement virtuel (Windows)
.venv\Scripts\activate

# Installer le LangGraph CLI avec l'extra inmem
pip install "langgraph-cli[inmem]"

LangGraph project structure

Three files are required for a basic LangGraph application:

mon-projet/
├── requirements.txt      # Fichier de dépendances (pip) ou pyproject.toml (poetry)
├── basic.py              # Fichier Python pour les fonctions du graphe
└── langgraph.json        # Fichier de configuration de l'API LangGraph

The project structure facilitates team collaboration and deployment to production. For experiments, you can also use Jupyter Notebooks, but this is not covered in this training.

Create required files

1. Dependencies file — requirements.txt

langgraph

You can also use poetry with a TOML file. In this example, we have a single dependency: LangGraph.

2. Python file — basic.py

For now, we create an empty file which we will fill later:

# basic.py — à compléter

3. LangGraph configuration file — langgraph.json

{
  "graphs": {
    "basic_graph": "./basic.py:graph"
  },
  "dependencies": [
    "."
  ]
}

This file has two keys:

  • graphs: lists the available graphs and their locations. The basic_graph key points to the graph object defined in basic.py.
  • dependencies: list paths to dependencies files. The . indicates to search in the current directory (where requirements.txt is located).

Important: The variable name in basic.py (here graph) must correspond exactly to what is defined in langgraph.json, otherwise an error will occur at startup.


1.3 — Define a simple workflow

Example: Airport check-in agent

We will build an airport check-in agent which:

  1. Requests a passenger’s name and flight number.
  2. Searches this information to verify if the passenger is eligible for an upgrade.
  3. If yes: include upgrade information in the output message.
  4. If no: gives standard confirmation.

The three main sections of a LangGraph workflow

Any LangGraph workflow in Python consists of three main sections:

SectionDescription
State objectsWhat we use to track data throughout the workflow
Node and helper functionsThe concrete logic of each step of the workflow
Graph constructionHow nodes and edges are connected

Section 1 — The State object: FlightState

from typing_extensions import TypedDict, Optional

class FlightState(TypedDict):
    name: str
    flight_number: str
    upgrade: Optional[bool]
    message: Optional[str]
  • name and flight_number: the initial entries, of type str.
  • upgrade: will be True or False depending on the result.
  • message: tracks information to display throughout the workflow.
  • upgrade and message are marked Optional — not for strict validation in this example, but to make the LangGraph Studio interface clearer at runtime.

FlightState inherits from TypedDict. It is the lightest and simplest form of state object.

Section 2 — The nodes and helper functions

Node check_in

def check_in(state: FlightState) -> FlightState:
    state["message"] = (
        f"Checking in {state['name']} "
        f"on flight {state['flight_number']}."
    )
    return state

Puts the flight name and number in the message.

Node offer_upgrade

def offer_upgrade(state: FlightState) -> FlightState:
    state["message"] = (
        f"Upgrade confirmed for {state['name']} ",
        f"on flight {state['flight_number']}! Safe travels."
    )
    return state

Simulates adding an upgrade to the flight by modifying the message.

Node confirm_check_in

def confirm_check_in(state: FlightState) -> FlightState:
    state["message"] = (
        f"Check-in confirmed for {state['name']} ",
        f"on flight {state['flight_number']}! Safe travels."
    )
    return state

Creates a message that simulates a normal flight check-in.

Helper function check_upgrade

import random
from typing import Literal

def check_upgrade(
    state: FlightState
) -> Literal["confirm_check_in", "offer_upgrade"]:
    # Simule la recherche du statut depuis une source de données
    if random.random() < 0.5:
        state["upgrade"] = True
        return "offer_upgrade"

    state["upgrade"] = False
    return "confirm_check_in"

The key difference: this helper function returns a Literal indicating which node to execute next depending on the result. If the passenger has an upgrade, we execute offer_upgrade; otherwise, confirm_check_in.

In this example, we use a random number with a 50% chance of obtaining an upgrade to simulate a real verification.

Section 3 — Graph construction

from langgraph.graph import StateGraph, START, END

# Créer le builder avec le state object
builder = StateGraph(FlightState)

# Ajouter les nodes
builder.add_node("check_in", check_in)
builder.add_node("offer_upgrade", offer_upgrade)
builder.add_node("confirm_check_in", confirm_check_in)

# Définir les edges
builder.add_edge(START, "check_in")
builder.add_conditional_edges("check_in", check_upgrade)
builder.add_edge("offer_upgrade", END)
builder.add_edge("confirm_check_in", END)

# Compiler le graphe
graph = builder.compile()

Key points:

  • StateGraph(FlightState): creates the graph by passing it the state object. This allows each function to access and modify the shared state object as it passes through the graph.
  • START and END: special nodes imported from the LangGraph package. Every state graph must have a start node and at least one end node.
  • add_edge(START, "check_in"): creates a direct edge from start to check_in.
  • add_conditional_edges("check_in", check_upgrade): check_in has conditional edges — we pass the helper function which implements the condition and returns which node to execute next.
  • The two terminal nodes (offer_upgrade and confirm_check_in) lead to END.
  • builder.compile(): compiles the graph and assigns it to the graph variable. This variable name must match the one defined in langgraph.json.

Workflow visualization

graph TD
    START([__start__]) --> check_in["check_in\nCrée le message initial"]
    check_in -->|"check_upgrade()\nupgrade = True"| offer_upgrade["offer_upgrade\nAjoute l'upgrade au message"]
    check_in -->|"check_upgrade()\nupgrade = False"| confirm_check_in["confirm_check_in\nConfirme le check-in standard"]
    offer_upgrade --> END([__end__])
    confirm_check_in --> END([__end__])

    style START fill:#2d6a4f,color:#fff
    style END fill:#2d6a4f,color:#fff
    style check_in fill:#1565c0,color:#fff
    style offer_upgrade fill:#6a1e55,color:#fff
    style confirm_check_in fill:#6a1e55,color:#fff

Full file basic.py

from typing_extensions import TypedDict, Optional

class FlightState(TypedDict):
    name: str
    flight_number: str
    upgrade: Optional[bool]
    message: Optional[str]

def check_in(state: FlightState) -> FlightState:
    state["message"] = (
        f"Checking in {state['name']} "
        f"on flight {state['flight_number']}."
    )
    return state

def offer_upgrade(state: FlightState) -> FlightState:
    state["message"] = (
        f"Upgrade confirmed for {state['name']} ",
        f"on flight {state['flight_number']}! Safe travels."
    )
    return state

def confirm_check_in(state: FlightState) -> FlightState:
    state["message"] = (
        f"Check-in confirmed for {state['name']} ",
        f"on flight {state['flight_number']}! Safe travels."
    )
    return state

import random
from typing import Literal

def check_upgrade(
    state: FlightState
) -> Literal["confirm_check_in", "offer_upgrade"]:
    # Simule la recherche du statut depuis une source de données
    if random.random() < 0.5:
        state["upgrade"] = True
        return "offer_upgrade"

    state["upgrade"] = False
    return "confirm_check_in"

from langgraph.graph import StateGraph, START, END

builder = StateGraph(FlightState)
builder.add_node("check_in", check_in)
builder.add_node("offer_upgrade", offer_upgrade)
builder.add_node("confirm_check_in", confirm_check_in)

builder.add_edge(START, "check_in")
builder.add_conditional_edges("check_in", check_upgrade)
builder.add_edge("offer_upgrade", END)
builder.add_edge("confirm_check_in", END)

graph = builder.compile()

1.4 — Run your workflow

Getting started with the LangGraph CLI

# Aller dans le répertoire contenant les fichiers
cd mon-projet

# Démarrer le serveur local
langgraph dev

This command:

  1. Starts a local instance of the server.
  2. Automatically launches a web page with LangGraph Studio.

LangGraph Studio connects to the local instance via the base URL parameter. Everything runs in memory, so nothing is persisted. This configuration allows LangGraph Studio to be used to run and debug a local version of the application. Any code change is detected and reloaded within seconds, saving time.

Step through an execution in LangGraph Studio

Workflow visualization

LangGraph Studio displays a visualization of the workflow with:

  • The starting (__start__) and ending (__end__) node
  • The check_in node
  • Two conditional edges to offer_upgrade and confirm_check_in

Inputs and startup

The workflow inputs are displayed in the interface. We note:

  • Two required fields: name and flight_number
  • Two optional fields: upgrade and message

Enter the name and flight number values, then click Submit to start the workflow.

Review of the status at each node (thread)

Execution is very fast. We can examine the state at each node for this thread:

  1. Node __start__: displays the flight_number and the name provided as input.
  2. Node check_in: creates the first message. If the offer_upgrade path is taken, the message is modified to show this.
  3. Final checkpoint: a checkpoint is created at the end of the workflow, showing the final state.

We can restart the check_in node until it takes the other conditional edge. With a 50/50 chance, it shouldn’t take too many tries. We can then see the message from the confirm_check_in node as the final result.

LangGraph Studio Features

Change state and fork an execution

You can edit the state of a node, then fork a new execution from this node with the modified state. For example, we can change the name in the report and click Fork. The message will then be updated to include the new name.

Create a new thread

To create a new thread, click on the corresponding button. You can enter different values ​​to run the workflow again.

Go back to previous threads

We can return to previous threads and examine the results or restart from certain nodes.

Output console

You can view the detailed execution logs and application output messages in the console where langgraph dev was launched.

sequenceDiagram
    participant U as Utilisateur
    participant S as LangGraph Studio
    participant A as Application locale

    U->>S: Entrer name + flight_number
    U->>S: Cliquer Submit
    S->>A: Démarrer le workflow
    A->>A: check_in (crée le message)
    A->>A: check_upgrade (50/50)
    alt upgrade = True
        A->>A: offer_upgrade
    else upgrade = False
        A->>A: confirm_check_in
    end
    A->>S: État final (checkpoint)
    S->>U: Visualiser chaque node + état

    Note over U,A: Fork possible depuis n'importe quel node
    U->>S: Modifier état + Fork
    S->>A: Relancer depuis ce node
    A->>S: Nouveau thread

2. Add memory to LangGraph workflows


2.1 — Memory in workflows

Role of memory

Memory helps the LangGraph workflow accomplish complex tasks. Memory can be added by defining a state object — simply a Python object that is passed between nodes. It contains all the information that the workflow is currently tracking.

Options for state objects

TypeDescriptionUse cases
TypedDictLightweight and simple to implementExperimentation, simple workflows
PydanticStructured data with validation and defaults, excellent for JSON serializationProduction workflows
Custom classesCustom classes for the state objectComplex workflows requiring reacting to data changes or transformations
External memoryExternal memory via LangChain CloudMemory tracking across multiple sessions

TypedDict is lightweight and simple to implement, which works well when experimenting with a workflow.

Pydantic allows you to define structured data, add validation and default values. It’s also great for JSON serialization.

For complex workflows, defining custom classes for state can make it easier to trigger certain changes or perform data transformations.

LangGraph supports external memory via LangChain Cloud, which helps track memory across multiple workflow sessions. We can also manually integrate other memory stores, such as cache systems and databases.

Not all of these options are covered in detail in this training, but they give an idea of ​​what is available.


2.2 — Use Pydantic templates

Converting from TypedDict to Pydantic

Let’s take the simple workflow that uses TypedDict for state and convert it to use a Pydantic model.

Before — with TypedDict:

from typing_extensions import TypedDict, Optional

class FlightState(TypedDict):
    name: str
    flight_number: str
    upgrade: Optional[bool]
    message: Optional[str]

After — with Pydantic BaseModel:

from pydantic import BaseModel
from typing_extensions import Optional

class FlightState(BaseModel):
    name: str
    flight_number: str
    upgrade: Optional[bool] = None
    message: Optional[str] = None

The key differences:

  • We inherit from BaseModel instead of TypedDict.
  • Optional fields have a default value (= None) — imposed by Pydantic.

Update node functions

With Pydantic, we access attributes with the dotted notation instead of square brackets:

Before (TypedDict):

def check_in(state: FlightState) -> FlightState:
    state["message"] = (
        f"Checking in {state['name']} "
        f"on flight {state['flight_number']}."
    )
    return state

After (Pydantic):

def check_in(state: FlightState) -> FlightState:
    state.message = (
        f"Checking in {state.name} "
        f"on flight {state.flight_number}."
    )
    return state

You can choose Pydantic simply to avoid brackets and quotation marks. Dotted notation is cleaner.

Full file basic2.py (Pydantic version)

from pydantic import BaseModel
from typing_extensions import Optional

class FlightState(BaseModel):
    name: str
    flight_number: str
    upgrade: Optional[bool] = None
    message: Optional[str] = None

def check_in(state: FlightState) -> FlightState:
    state.message = (
        f"Checking in {state.name} "
        f"on flight {state.flight_number}."
    )
    return state

def offer_upgrade(state: FlightState) -> FlightState:
    state.message = (
        f"Upgrade confirmed for {state.name} "
        f"on flight {state.flight_number}! Safe travels."
    )
    return state

def confirm_check_in(state: FlightState) -> FlightState:
    state.message = (
        f"Check-in confirmed for {state.name} "
        f"on flight {state.flight_number}! Safe travels."
    )
    return state

import random
from typing import Literal

def check_upgrade(
    state: FlightState
) -> Literal["confirm_check_in", "offer_upgrade"]:
    # Simule la recherche du statut depuis une source de données
    if random.random() < 0.5:
        state.upgrade = True
        return "offer_upgrade"

    state.upgrade = False
    return "confirm_check_in"

from langgraph.graph import StateGraph, START, END

# -- Build Graph --
builder = StateGraph(FlightState)
builder.add_node("check_in", check_in)
builder.add_node("offer_upgrade", offer_upgrade)
builder.add_node("confirm_check_in", confirm_check_in)

builder.add_edge(START, "check_in")
builder.add_conditional_edges("check_in", check_upgrade)
builder.add_edge("offer_upgrade", END)
builder.add_edge("confirm_check_in", END)

graph = builder.compile()

Checking in LangGraph Studio

To verify the changes:

  1. Start LangGraph Studio (langgraph dev).
  2. Enter the input values.
  3. Click Submit to run the workflow.
  4. Verify that it runs without errors.
  5. Relaunch several times to see the different conditional edges.

3. Debug and monitor with LangGraph Studio


3.1 — Fix errors locally

Identify errors in LangGraph Studio

Running LangGraph Studio locally is a great way to debug your workflows. Here is what we can do:

After entering values and launching the graph, if an error occurs:

  • Red error box: appears next to the node in question (eg: confirm_check_in), to immediately identify where the problem occurred.
  • Error information: Displayed in the interface — for example, that it was a TypeError.
  • Expand tour: allows you to see the node where it happened with the details of the error.
  • Error tag: even if a node is reduced, a tag remains visible, which is practical in a large graph.

Output console

For even more information, consult the output console:

  • The code that had the error.
  • The affected file and line number.
TypeError: can only concatenate str (not "tuple") to str
  File "/path/to/basic.py", line 27, in confirm_check_in

Hot reloading

Once the code has been corrected, we look at the console: LangGraph automatically detects the change and reloads the application. This is hot swapping in action. There is no need to restart the server.

Re-run from here — Rerun from a specific node

To quickly test the fix:

  1. Use the Re-run from here functionality before the node which had an error.
  2. In this example, the node state check_in will be loaded, then confirm_check_in will be called again.
  3. After execution, it can be confirmed that the fix worked.

Note: LangGraph Studio creates a new fork for this node. It remembers previous forks, so we can go back and review them.

graph LR
    check_in["check_in\n(état sauvegardé)"] --> fork1["confirm_check_in\n(erreur — fork 1)"]
    check_in --> fork2["confirm_check_in\n(corrigé — fork 2)"]
    fork1 --> END1([__end__])
    fork2 --> END2([__end__])

    style fork1 fill:#c62828,color:#fff
    style fork2 fill:#2e7d32,color:#fff

3.2 — Use interrupts

What is an interrupt?

Interrupts are like breakpoints that can be set before or after the execution of a node. They allow execution to be paused to examine the state at a specific time.

How to install switches

Method 1 — Via the graph

We hover over a node in the graph, then we select:

  • Interrupt Before: pause before node execution
  • Interrupt After: pause after node execution
  • Both: both

Nodes that have interrupts configured are identifiable by shaded lines in their boxes.

Method 2 — Via the interrupts menu

LangGraph Studio offers a menu listing all the interrupts in the graph. This is an easy way to configure or clear interrupts for all nodes at once.

Example: interrupt before check_in

  1. Place an interrupt before the check_in node.
  2. Start graph execution.
  3. Execution pauses — status can be examined.
  4. Once ready, click Continue to resume execution.
sequenceDiagram
    participant U as Utilisateur
    participant S as LangGraph Studio

    U->>S: Configurer "Interrupt Before check_in"
    U->>S: Submit (démarrer le workflow)
    S-->>U: ⏸ PAUSE — état affiché avant check_in
    U->>U: Examiner l'état actuel
    U->>S: Cliquer Continue
    S->>S: Reprendre l'exécution (check_in → suite)
    S-->>U: Résultat final

3.3 — Reminder of the basics

LangGraph is a Python application

When running a LangGraph workflow locally, keep in mind that it is a Python application. We can therefore apply all the normal good practices:

  • Logger: use a logger to organize what appears in the logs.
  • Try/except: use standard Python error handling.
import logging

logger = logging.getLogger(__name__)

def check_in(state: FlightState) -> FlightState:
    try:
        logger.info(f"Début du check-in pour {state['name']}")
        state["message"] = (
            f"Checking in {state['name']} "
            f"on flight {state['flight_number']}."
        )
        logger.info(f"Message créé : {state['message']}")
        return state
    except Exception as e:
        logger.error(f"Erreur dans check_in : {e}")
        raise

Common errors to watch for

ErrorDescription
Do not update state between nodesState is not changed or returned correctly
Type mismatchMismatch between expected type and actual value
Forgetting to return a new statenode function does not return modified state
ErrorDescription
Missing edgesA node has no exit path
Circular edgesInfinite loop between nodes
Incorrect condition logicThe condition returns a nonexistent node
Duplicate node referencesA node is incorrectly referenced several times
Common errors in node functions
ErrorDescription
Forgetting to return a resultThe function does not return the state
Incorrect function signatureParameters do not match what LangGraph expects
Syntax or logic errorsClassic Python Bugs

Versioning

As with any Python application, keeping LangGraph and associated libraries up to date and using compatible versions helps avoid problems.

# Mettre à jour LangGraph
pip install --upgrade langgraph

# Vérifier les versions installées
pip show langgraph

4. Appendices — Complete code files

Complete project structure (Module 1)

m1/
├── requirements.txt
├── langgraph.json
└── basic.py

requirements.txt

langgraph

langgraph.json

{
  "graphs": {
    "basic_graph": "./basic.py:graph"
  },
  "dependencies": [
    "."
  ]
}

basic.py — TypedDict version (Module 1)

from typing_extensions import TypedDict, Optional

# ─────────────────────────────────────────────
# STATE OBJECT
# ─────────────────────────────────────────────

class FlightState(TypedDict):
    name: str
    flight_number: str
    upgrade: Optional[bool]
    message: Optional[str]

# ─────────────────────────────────────────────
# NODE FUNCTIONS
# ─────────────────────────────────────────────

def check_in(state: FlightState) -> FlightState:
    state["message"] = (
        f"Checking in {state['name']} "
        f"on flight {state['flight_number']}."
    )
    return state

def offer_upgrade(state: FlightState) -> FlightState:
    state["message"] = (
        f"Upgrade confirmed for {state['name']} ",
        f"on flight {state['flight_number']}! Safe travels."
    )
    return state

def confirm_check_in(state: FlightState) -> FlightState:
    state["message"] = (
        f"Check-in confirmed for {state['name']} ",
        f"on flight {state['flight_number']}! Safe travels."
    )
    return state

# ─────────────────────────────────────────────
# HELPER FUNCTION (conditional edge)
# ─────────────────────────────────────────────

import random
from typing import Literal

def check_upgrade(
    state: FlightState
) -> Literal["confirm_check_in", "offer_upgrade"]:
    # Simule la recherche du statut depuis une source de données
    if random.random() < 0.5:
        state["upgrade"] = True
        return "offer_upgrade"

    state["upgrade"] = False
    return "confirm_check_in"

# ─────────────────────────────────────────────
# GRAPH CONSTRUCTION
# ─────────────────────────────────────────────

from langgraph.graph import StateGraph, START, END

builder = StateGraph(FlightState)

builder.add_node("check_in", check_in)
builder.add_node("offer_upgrade", offer_upgrade)
builder.add_node("confirm_check_in", confirm_check_in)

builder.add_edge(START, "check_in")
builder.add_conditional_edges("check_in", check_upgrade)
builder.add_edge("offer_upgrade", END)
builder.add_edge("confirm_check_in", END)

graph = builder.compile()

basic2.py — Pydantic version (Module 2 & 3)

from pydantic import BaseModel
from typing_extensions import Optional

# ─────────────────────────────────────────────
# STATE OBJECT (Pydantic)
# ─────────────────────────────────────────────

class FlightState(BaseModel):
    name: str
    flight_number: str
    upgrade: Optional[bool] = None
    message: Optional[str] = None

# ─────────────────────────────────────────────
# NODE FUNCTIONS
# ─────────────────────────────────────────────

def check_in(state: FlightState) -> FlightState:
    state.message = (
        f"Checking in {state.name} "
        f"on flight {state.flight_number}."
    )
    return state

def offer_upgrade(state: FlightState) -> FlightState:
    state.message = (
        f"Upgrade confirmed for {state.name} "
        f"on flight {state.flight_number}! Safe travels."
    )
    return state

def confirm_check_in(state: FlightState) -> FlightState:
    state.message = (
        f"Check-in confirmed for {state.name} "
        f"on flight {state.flight_number}! Safe travels."
    )
    return state

# ─────────────────────────────────────────────
# HELPER FUNCTION (conditional edge)
# ─────────────────────────────────────────────

import random
from typing import Literal

def check_upgrade(
    state: FlightState
) -> Literal["confirm_check_in", "offer_upgrade"]:
    # Simule la recherche du statut depuis une source de données
    if random.random() < 0.5:
        state.upgrade = True
        return "offer_upgrade"

    state.upgrade = False
    return "confirm_check_in"

# ─────────────────────────────────────────────
# GRAPH CONSTRUCTION
# ─────────────────────────────────────────────

from langgraph.graph import StateGraph, START, END

builder = StateGraph(FlightState)
builder.add_node("check_in", check_in)
builder.add_node("offer_upgrade", offer_upgrade)
builder.add_node("confirm_check_in", confirm_check_in)

builder.add_edge(START, "check_in")
builder.add_conditional_edges("check_in", check_upgrade)
builder.add_edge("offer_upgrade", END)
builder.add_edge("confirm_check_in", END)

graph = builder.compile()

Summary of key concepts

ConceptDescription
StateGraphMain class to construct a LangGraph graph with a state object
State objectPython object passed between nodes to share and track data
NodePython function that receives state, performs an action, and returns the modified state
EdgeDirect connection between two nodes (add_edge)
Conditional edgeConditional connection determined by a helper function (add_conditional_edges)
START / END ​​Special nodes imported from langgraph.graph to mark start and end
TypedDictLightweight Python type to define state object
Pydantic BaseModelPydantic class to define state object with validation and default values ​​
LangGraph CLICLI tool to start the application locally (langgraph dev)
LangGraph StudioWeb interface to visualize, debug and monitor workflows
inmemLangGraph CLI extra activating hot reloading
Hot reloadingAutomatic reloading of code changes without restarting the server
InterruptBreakpoint LangGraph Studio — break before/after a node
ForkNew execution branch created from a node with a modified state
ThreadIndependent execution of the workflow with its own inputs
langgraph.jsonConfiguration file declaring available graphs and dependencies


Search Terms

langgraph · workflows · ai · agents · orchestration · artificial · intelligence · generative · errors · studio · workflow · pydantic · functions · memory · node · version · basic.py · basic2.py · cli · interrupt · state · typeddict

Interested in this course?

Contact us to book it or get a custom training plan for your team.