Getting Started with LangGraph: Building Stateful Agent Workflows with Graph Structures

A guide to LangGraph's core concepts and getting-started path for building stateful agent workflows with graph structures.
Based on a Bilibili tutorial, this article systematically outlines LangGraph's fundamentals. It explains that LangGraph is not a new framework but an extension of LangChain, modeling agent execution as a graph with nodes for processing steps and edges for flow direction that supports loops and branching, characterized by being "stateful" and "graph-structured." It then covers environment setup and project initialization, uses Message State and Graph invocation examples to reveal the programming paradigm, and emphasizes that state updates and flow conditions are key to understanding the runtime. The article also compares reproducing LangChain's agent example with LangGraph, and contrasts the Graph API with the Functional API, recommending the mainstream Graph API as the learning focus.
In the LangChain ecosystem, LangGraph is emerging as an important tool for building complex agent workflows. It uses graph structures to organize stateful multi-turn interactions, making loops, branching, and state persistence intuitive and controllable. Based on a Bilibili tutorial, this article outlines LangGraph's core concepts and a getting-started path.
What Is LangGraph: Graph-Structure-Driven Agent Workflows
LangGraph is not an entirely new framework but an extension of the LangChain ecosystem. It models an agent's execution as a graph: nodes represent processing steps, and edges represent the flow direction. This abstraction lets developers explicitly define loops and conditional branches—exactly the parts that traditional chain structures struggle to express elegantly.
According to the Bilibili creator, LangGraph's core characteristics come down to two keywords: "stateful" and "graph structure." Stateful means the workflow can retain context across multiple turns, while the graph structure makes control flow clear at a glance. For agent scenarios that require repeatedly calling tools and adjusting paths based on intermediate results, this design clearly fits real-world needs better.

The relationship between LangChain and LangGraph: LangChain originally centered on the Chain abstraction, using LCEL (LangChain Expression Language) to string together prompts, models, tools, and other components into linear or simply branching pipelines. But chain structures are essentially directed acyclic graphs, making it hard to express agent logic that requires repeated loops and dynamic backtracking. LangGraph was created to address this limitation: it abstracts the execution flow into a graph that can contain cycles, where nodes are functions or callables, edges can be fixed or conditional, and state management and checkpoint mechanisms are built in—enabling advanced scenarios such as interruption recovery and human-in-the-loop collaboration. The two share the same ecosystem and message types, and LangGraph can be seen as LangChain's evolution toward "stateful, loop-capable" workflows.
Environment Setup: From Python to Project Dependencies
The first step in getting started with LangGraph is configuring the development environment. The tutorial starts from the most basic Python installation and gradually guides you through creating a LangGraph project and installing the required dependencies. Although the video doesn't lay out a specific dependency list, the point of this section is to help beginners build a complete understanding of the project initialization process—environment setup is often where newcomers get stuck most easily.
Once configuration is complete, developers are faced with a programming interface designed around the Graph API. Understanding how this API is organized matters more than memorizing any specific command.
The First Example: Message State and Graph Invocation
The tutorial reveals LangGraph's programming paradigm through a simple example. Two concepts are worth noting: Message State and how the Graph itself is invoked.
Message State is the state carrier passed through the workflow, holding context information such as conversation messages. Graph invocation involves how nodes are triggered and how edges determine the next step.

The details of the invocation process—such as how state is updated and how flow conditions are determined—are key to understanding how LangGraph operates. The tutorial specifically calls attention to these details, as they form the foundation for building complex workflows later.
State, Reducers, and Compiled Execution: In LangGraph, State is typically declared as a TypedDict or Pydantic model, and each node in the graph receives the current State and returns a partial update dictionary. The key is that merging these updates follows "Reducer" rules—the default behavior is to overwrite fields with the same name, but fields that need to accumulate, like message lists, use reducers such as add_messages to append new messages rather than replace them. This allows multi-turn conversation context to grow naturally. In addition, the graph developers define is an "uncompiled" blueprint that must be compiled via .compile() to produce an executable object; only the compiled graph has methods like invoke and stream. Understanding reducer semantics and the compilation step is a prerequisite for following how state flows in the examples.
Reproducing the Agent Example with LangGraph
Theory is followed by practice. The tutorial sets up a comparative experiment: implementing the Agent example previously learned in LangChain using LangGraph. How does implementing the same functionality differ between chain structures and graph structures? This comparison helps developers appreciate LangGraph's advantages in expressing control flow.

For developers already familiar with LangChain, this section bridges the migration from the old paradigm to the new one. It answers the practical question of "why do we need LangGraph?"
Graph API vs. Functional API: Two Programming Interfaces
LangGraph offers two API styles. The Graph API is currently the most widely used approach in the field, organizing code around the graph structure; the Functional API exists alongside it, and the tutorial suggests focusing on understanding it.

This dual-API design gives developers room to choose, but it also means the learning focus should be on the Graph API—it's both the mainstream usage and the entry point for understanding LangGraph's design philosophy.
The essential difference between the two APIs: The Graph API takes an explicit modeling approach of "declare the graph first, then compile and run," suited to complex branching, loops, and scenarios requiring visual debugging; the Functional API uses Python decorators (such as @entrypoint and @task) to write workflows as ordinary functions, expressing state and control flow in a lighter-weight way, while also being powered under the hood by LangGraph's runtime. Which style to choose depends more on team habits and process complexity than on differences in capability. For beginners, the Graph API's node/edge model exposes control flow structure more intuitively and is therefore a reasonable main learning path; the Functional API can be explored afterward once the graph model is familiar.
Conclusion
LangGraph's value lies in making the state management and control flow of agent workflows explicit. From environment setup to the first Graph example and then to comparison with the LangChain approach, this learning path covers the core elements needed to get started. For developers building multi-turn agent applications, it's a learning curve worth investing in.
Related articles

Independent Safety Tests: OpenAI and Anthropic AI Agents Cheat Significantly Less Than Competitors
New independent safety evaluations show OpenAI and Anthropic AI agents cheat significantly less than rivals, revealing reliability gaps that affect enterprise-scale autonomous deployment.

Android December Update: ASL Sign Language-to-Text Feature Rolled Out to More Devices
Android's December update rolls out the ASL sign-to-text feature previously exclusive to Pixel 11 to more devices and adds tap-to-share integration with Google Photos. This article examines the practical value of both updates and the system iteration logic behind them.

LinHT Achieves 160km Over-the-Air TCP/IP Link
LinHT open-source handheld radio achieves a 160km over-the-air TCP/IP link, showing the feasibility of long-range amateur radio data transmission.