Beginner

Introduction to LangGraph

This introductory module presents LangGraph in its entirety: what it is, why it was created, and the main building blocks that make it up (state management, graphs, testing/debugging, dep...

Table of Contents


1. Introduction to LangGraph

This introductory module presents LangGraph in its entirety: what it is, why it was created, and the main building blocks that make it up (state management, graphs, testing/debugging, deployment). It is an overview which prepares the following modules where we concretely implement each concept.


Lesson 1: What Is LangGraph?

AI agents and multi-agent systems

To answer the question what is LangGraph, we must first agree on what an AI agent is.

An AI agent is like an assistant who can accomplish something for you. Agents have become really useful with the advent of LLM (Large Language Models) such as ChatGPT. Different agents are good at different things. A single agent can accomplish most simple tasks.

If you need to do something more complex, you can perform multiple steps by combining different agents. This is what we call a multi-agent system.

A simple multi-agent system is linear: everything happens in a sequence of steps — A, then B, then C. More complex multi-agent systems look like a flow chart. You can take different paths through the system depending on the data or depending on the decisions made by the AI ​​agents inside the workflow.

Système multi-agent simple (linéaire) :
  Agent A → Agent B → Agent C

Système multi-agent complexe (flow chart) :
  Agent A → [décision] → Agent B1 ou Agent B2
                              ↓           ↓
                           Agent C     Agent D

What LangGraph brings

LangGraph was created to manage the entire lifecycle of AI agent systems. It provides code libraries and defines patterns to develop your agents.

Here is what LangGraph offers:

FeatureDescription
Multiple LLM providersYou can use multiple LLM providers in your system
Single & multi-agentLangGraph supports both single-agent and multi-agent systems
State managementHelps AI agents remember what they’ve done and communicate with each other
Testing/Debugging ToolsHelps find and fix bugs before they become a problem
Docker containersPackages deployment into Docker container for consistent releases
ScalingProvides an environment where your system can easily ramp up or down
TracesMeasures the reliability and performance of your system

State management: the memory of agents

LangGraph helps AI agents remember what they did and communicate with other agents via state management, which is basically a form of memory.

No state management problem: Not all frameworks have state management built in, which can lead to forgetful chatbots that frustrate your users.

Testing, debugging and deployment

Some early AI applications had problems with:

  • Private data leaks (privacy leaks)
  • Biased output
  • Security problems (security problems)

These applications were not subjected to appropriate testing and validation before being released into production. LangGraph provides tools to test and debug your AI agents, to find and fix bugs before they become a problem for your users.

Regarding deployment: An inconsistent deployment process can cause problems, and applications that don’t scale respond slowly or not at all. LangGraph packages your deployment as a Docker container. With Docker, you can include exactly what you need, making your releases consistent.

Reliability and Metrics

LangGraph also provides an environment where your system can easily scale up and down depending on traffic variations.

LangGraph has traces to measure the reliability of your system:

  • Does it do what it’s supposed to do?
  • Traces let you see actual usage
  • Performance metrics: LLM response time and cost

With this information, you can adjust your agents and then measure the results. Now let’s take a closer look at some of LangGraph’s foundations and features, as well as what you’ll need to use it.


Lesson 2: Understanding State

What is State?

state refers to the current condition or memory of a system — what it knows at the moment. For AI agents, state is the information available for agents to process.

Stateful agents

A stateful agent keeps track of past information, so the conversation flows naturally. He remembers what you told him, so you don’t have to repeat yourself.

LangGraph provides built-in mechanisms for:

  • Save information regarding the state
  • Make this information available throughout the workflow
  • Allow agents to know what other agents have done
  • Update state information as you go

State management helps your agents accomplish complex tasks in a natural way, like working with a real assistant.

The concept of State Machine

When using LangGraph, it is useful to think of your workflow as a state machine.

Definition: A state machine is a model in which a system can be in one of many states, and it transitions between them based on inputs or conditions.

stateDiagram-v2
    [*] --> Idle : démarrage
    Idle --> PassengerIdentification : passager arrive
    PassengerIdentification --> FlightLookup : référence saisie
    FlightLookup --> FlightConfirmation : vol trouvé
    FlightLookup --> ErrorState : vol non trouvé
    ErrorState --> PassengerIdentification : réessayer
    FlightConfirmation --> BaggageOptions : confirmation OK
    BaggageOptions --> BaggageTagPrinting : nombre de bagages confirmé
    BaggageTagPrinting --> [*] : fin

Concrete example: baggage check-in terminal

A baggage check-in terminal in an airport perfectly illustrates a state machine. It can have the following states:

StateDescription
Idle / StartWaiting for a passenger to start check-in
Passenger IdentificationRequest a booking reference, passport scan or frequent flyer number
Flight LookupSearching for a flight based on what the passenger entered
Flight ConfirmationViewing flight details and requesting confirmation
Baggage OptionsAsks how much baggage should be checked in
Baggage Tag PrintingPrinting baggage tags and instructing the passenger to attach them

Each of these states represents something the terminal can do. It moves from one state to the next based on user input or system actions (like querying a database).

You can also add error states to handle incorrect or missing information. These states could retry the current action or return to the beginning.

What State Machines can model

State machines help you consider:

  1. The overall capacity of your workflow
  2. What information each state requires to accomplish its task
  3. Where you could take different paths depending on the outcome of a state

Lesson 3: Using Graphs for Workflows

The concept of graph applied to workflows

LangGraph defines workflows using — as its name suggests — graphs.

If you’ve ever flown, you’ve experienced a graph-based workflow:

  • Airports are nodes
  • Flights between airports are edges
  • The route you take from one city to another can vary: sometimes a direct flight, sometimes layovers in several cities

When you define a workflow with a graph, you create a map of what actions are available and the possible sequences of those actions. Graphs allow you to branch, loop, or take different routes depending on what’s happening, giving you more flexibility to model complex workflows.

Nodes and Edges in LangGraph

In LangGraph:

ComponentRoleExample
NodeRepresents an actionCall an LLM, query a database, invoke a tool
EdgeDefines where you can go after completing an actionTransition from one node to the next
Conditional EdgeEdge available only under certain conditionsProvides different options depending on the results of a node

conditional edges are edges that are only available sometimes. They provide different options depending on a node’s results.

The four workflow patterns in LangGraph

flowchart TD
    subgraph Sequential["1. Sequential Graph"]
        A1[Node A] --> B1[Node B] --> C1[Node C]
    end

    subgraph Branching["2. Branching Graph"]
        A2[Node A] --> D{Décision}
        D -->|condition 1| B2[Node B]
        D -->|condition 2| C2[Node C]
    end

    subgraph Cyclic["3. Cyclic Graph"]
        A3[Node A] --> B3[Node B]
        B3 --> C3{Objectif atteint?}
        C3 -->|Non| A3
        C3 -->|Oui| D3[Node D]
    end

    subgraph MultiAgent["4. Multi-Agent Graph"]
        AG1[Agent 1] --> S["(State partagé)"]
        AG2[Agent 2] --> S
        AG3[Agent 3] --> S
        S --> AG1
        S --> AG2
        S --> AG3
    end

Sequencers

A sequential graph is a basic linear sequence with only one possible path between the nodes: A, then B, then C.

Even though this doesn’t really require a graph, it can still be modeled as one, so it can be done in LangGraph.

flowchart LR
    A[Node A] --> B[Node B] --> C[Node C]

Branching Graphs

A branching graph has nodes with more than one conditional edge, where the AI ​​or a function makes a decision based on the input, then follows a different path depending on the edge conditions you defined.

flowchart TD
    A[Node A] --> D{Décision IA}
    D -->|résultat 1| B[Node B]
    D -->|résultat 2| C[Node C]
    B --> E[Node E]
    C --> E

Cyclic Graph

If you need to repeat actions, you will use a cyclic graph. This is where a node can perform a task and then loop back on itself until a certain goal is achieved. You can also define repetitive cycles between several nodes.

flowchart TD
    START([START]) --> A[Node A]
    A --> B[Node B]
    B --> C{Objectif atteint ?}
    C -->|Non, continuer| A
    C -->|Oui| END([END])

Multi-agent graphs

A multi-agent graph is one where different agents manage different parts of the workflow. LangGraph manages state in a way that allows agents to access information produced by other agents, even if they are not directly connected by edges in the graph.

flowchart TD
    INPUT([Entrée utilisateur]) --> ROUTER[Agent Router]
    ROUTER --> AGENT1[Agent 1\nRecherche]
    ROUTER --> AGENT2[Agent 2\nAnalyse]
    AGENT1 --> STATE["(State\nPartagé)"]
    AGENT2 --> STATE
    STATE --> AGENT3[Agent 3\nSynthèse]
    AGENT3 --> OUTPUT([Réponse finale])

Graphs as a visualization tool

Graphs also help visualize your workflow for testing and debugging. This is what we will see in the next lesson.


Lesson 4: Testing and Debugging in LangGraph

Why do software have bugs?

Do developers wake up in the morning thinking I’m going to write bugs today? No. Software systems are extremely complex. Google has over 2 billion lines of code to support its search. It’s easy for bugs to go unnoticed without proper testing tools.

Once you notice a bug, the next challenge is to find what caused it:

  • Was it because of data?
  • Has the system entered an incorrect state?

Having information to reproduce a bug helps you fix it faster.

LangGraph provides tools to test and debug your agents and workflows. Here are the essential points:

LangGraph Studio

LangGraph Studio generates a graphic diagram of your workflow. You can follow the execution through this diagram.

With live debugging mode, you can also:

  • Advance in the workflow one node at a time
  • Inspect inputs, outputs and state changes at each step
LangGraph Studio — Débogage pas à pas :
  [Node A] → exécuté ✓ → inspect state
  [Node B] → exécuté ✓ → inspect state
  [Conditional Edge] → chemin B pris
  [Node C] → en cours...

The Traces

Traces capture data about your workflow, like a flight recorder on an airplane. They allow you to see:

InformationDescription
Which route was takenWhat path did the workflow take
Triggering conditionsWhich conditions triggered which route
Information between nodesWhat was transmitted from one node to another
AI processingWhether the AI ​​processed the data as expected

Save State for diagnostics

The AI state can be saved so that you can diagnose problems using a snapshot of the state, rather than the current state which might have changed in the meantime.

This is the equivalent of a “snapshot” of the agent’s memory at a specific time — extremely useful for reproducing and analyzing bugs.

LangSmith: experiments and regression tests

LangSmith is a tool compatible with LangGraph that allows you to configure experiments (experiments). These experiences help you:

  • Compare AI responses before and after making changes to your workflow
  • Set up regression tests to ensure changes to your workflow won’t break anything critical
flowchart LR
    A[Modification du workflow] --> B[LangSmith Experiment]
    B --> C[Avant: réponse ancienne]
    B --> D[Après: réponse nouvelle]
    C --> E{Comparaison}
    D --> E
    E --> F[Régression détectée ?]
    F -->|Oui| G[Alerte / Fix]
    F -->|Non| H[Deploy en prod]

Monitoring of LLMs

You can monitor LLM performance with metrics such as:

MetricUtility
Failure rate (failure rate)Identify Untrusted Areas
Response timeIdentify slow zones
Cost (cost)Identify financially inefficient areas

This information helps you identify slow or inefficient areas of your workflow to optimize.

Overall benefits of testing

Testing your AI workflows helps you:

  1. Catch errors before users see them
  2. Ensuring reliable performance
  3. Improve security and privacy

Lesson 5: Where It Can All Fall Apart

Deployment: from dev to production

Once you have tested and debugged your system, you are only halfway there. The other half is deployment and scaling. If you rush through these steps, you could end up with a broken system.

Moving your application from development (where it is worked on and debugged) to production (where your customers actually use it) is called deployment.

Strategy TypeResult
Good deployment strategyConsistent and reproducible
Bad deployment strategyInstability and introduction of bugs that did not exist in development

Docker containers for LangGraph

LangGraph uses Docker containers to package workflows. These containers include everything your application needs:

  • Frameworks
  • Dependencies
  • Configurations

Advantages of Docker containers:

AdvantageDescription
ConsistencyDocker containers work the same way in dev or in prod
VersioningThey are versioned, making it easy to push new updates or rollback
InsulationEverything the app needs is included, nothing more

Horizontal vs. vertical scaling

To understand scaling, let’s go back to the airport:

Horizontal scaling: If you’re waiting in a line to check in for a flight and the airport suddenly opens 10 additional counters, that’s horizontal scaling — adding multiple units that can do the same job in parallel.

Vertical scaling: If you only keep one counter open and try to go faster, that’s an example of vertical scaling — adding more power to a single system.

flowchart LR
    subgraph Horizontal["Scaling Horizontal"]
        direction TB
        LB[Load Balancer] --> C1[Container 1]
        LB --> C2[Container 2]
        LB --> C3[Container 3]
        LB --> C4[Container 4]
    end

    subgraph Vertical["Scaling Vertical"]
        direction TB
        BIG[1 seul Container\ntrès puissant]
    end

The main objective of scaling is to:

  1. Handle more users in the same amount of time when demand rises
  2. Conserve resources when demand goes down

Docker is designed for horizontal scaling: you can quickly scale up and down the number of running instances to handle demand. The load is balanced between available containers. If a container has a problem, it is removed from traffic and a new one replaces it.

LangGraph Cloud: managed service

LangGraph Cloud is a managed service for deploying your LangGraph applications. A managed service manages for you:

  • Physical machines
  • versioning
  • scaling
  • monitoring

There are also several other options for running Docker containers, so you can leverage frameworks you already have if that makes more sense for you.


Lesson 6: What Else Do I Need to Know?

Python: the LangGraph language

LangGraph is a development framework. You will work in Python to define your workflows, write functions and call LLMs.

You will need a solid understanding of Python, including:

Basic Python:

  • Variables
  • Control statements
  • Functions

Advanced features:

Python functionalityUsefulness in LangGraph
Library managementDependency and package management
Error handlingError management in agents
ClassesModeling of agents and workflows
DecoratorsDecoration of LangGraph nodes and functions
TypedDictDefinition of typed state structures
Pydantic modelsValidating state data
Calling APIsInteraction with LLMs and external services

Interaction with LLMs

To interact with LLMs, you will need to create prompts to configure your agents to do the right job. So some experience with prompts is helpful.

LangChain vs direct API calls

Two approaches to calling LLMs:

ApproachDescriptionAdvantage
LangChainLibrary that abstracts calls to different LLM providersFlexibility between providers, unified API
Direct API callDirectly call the API of the LLM you are usingFull control, fewer dependencies

Necessary knowledge of State and Graphs

We covered state and graphs in this training. If this is completely new to you, a little more depth on these topics will help you when you implement more complex workflows.

Docker packaging and deployment

LangGraph provides a simple command to package your app into a Docker container. You might need to set some Dockerfile information depending on your dependencies.

To run Docker containers, you will need an environment and the skills to do so. Or if you use LangGraph Cloud, a lot of these details are handled for you.


2. General Summary

mindmap
  root((LangGraph))
    Agents IA
      Agent unique
      Systèmes multi-agents
      LLM multiples providers
    State Management
      Mémoire des agents
      State machine
      Partage entre agents
    Graphs
      Nodes = actions
      Edges = transitions
      Conditional edges
      Sequential
      Branching
      Cyclic
      Multi-agent
    Testing & Debugging
      LangGraph Studio
      Live debugging
      Traces
      State snapshots
      LangSmith
      Tests de régression
      Monitoring LLM
    Déploiement
      Docker containers
      Scaling horizontal
      LangGraph Cloud
      Service managé
    Prérequis
      Python avancé
      Prompts LLM
      LangChain
      State & Graphs

What LangGraph solves

ProblemLangGraph Solution
Forgetful agents / no memoryState management integrated
Complex workflows difficult to modelGraph-based workflows (nodes + edges)
Hard to find bugsLangGraph Studio + Traces + LangSmith
Inconsistent deploymentsDocker containers versioned
Difficult scalingHorizontal scaling with Docker / LangGraph Cloud
Lack of visibility into performanceMetrics (failure rate, response time, cost)

Key components

flowchart TD
    subgraph LangGraph["LangGraph Framework"]
        direction TB
        WF[Définition du Workflow\nPython + Graph] --> SM[State Machine\nState partagé]
        SM --> N1[Node 1\nAppel LLM]
        SM --> N2[Node 2\nOutil / DB]
        SM --> N3[Node 3\nLogique métier]
        N1 --> CE{Conditional Edge}
        N2 --> CE
        N3 --> CE
        CE -->|chemin A| NEXT1[Suite A]
        CE -->|chemin B| NEXT2[Suite B]
    end

    subgraph Tools["Outils LangGraph"]
        STUDIO[LangGraph Studio\nVisualisation + Debug]
        LANGSMITH[LangSmith\nExpériences + Tests]
        TRACES[Traces\nFlight recorder]
    end

    subgraph Deploy["Déploiement"]
        DOCKER[Docker Container]
        CLOUD[LangGraph Cloud\nService managé]
    end

    LangGraph --> Tools
    LangGraph --> Deploy

3. Architectural Overview

flowchart LR
    USER([Utilisateur]) --> WORKFLOW

    subgraph WORKFLOW["Workflow LangGraph"]
        direction TB
        START([START]) --> NODE_A[Node A\nAgent LLM]
        NODE_A --> STATE["(State\nMémoire partagée)"]
        STATE --> NODE_B[Node B\nOutil externe]
        NODE_B --> COND{Condition ?}
        COND -->|Oui| NODE_C[Node C\nRésultat final]
        COND -->|Non| NODE_A
        NODE_C --> END([END])
    end

    subgraph PROVIDERS["LLM Providers"]
        GPT[OpenAI GPT]
        CLAUDE[Anthropic Claude]
        OTHER[Autres...]
    end

    subgraph DEBUG["Testing & Debug"]
        STUDIO[LangGraph Studio]
        LANGSMITH2[LangSmith]
        TRACES2[Traces]
    end

    subgraph INFRA["Infrastructure"]
        DOCKER2[Docker Container]
        LGCLOUD[LangGraph Cloud]
    end

    NODE_A <-->|LangChain / API| PROVIDERS
    WORKFLOW --> DEBUG
    WORKFLOW --> INFRA
    INFRA --> USER


Search Terms

langgraph · ai · agents · orchestration · artificial · intelligence · generative · state · graphs · deployment · testing · concept · debugging · docker · graph · llms · multi-agent · workflows

Interested in this course?

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