0Pricing
AI Engineering Academy · Lesson

Building Multi-Agent Pipelines with LangGraph

Use LangGraph to define agent nodes, conditional edges, and shared state in a directed graph, enabling complex multi-agent workflows with loops, branching, and human-in-the-loop checkpoints.

What Is LangGraph?

LangGraph is a library built on top of LangChain that lets you define multi-agent workflows as directed graphs. Nodes in the graph represent agents or processing steps, edges represent the flow of state between them, and conditional edges allow dynamic routing based on the current state. LangGraph handles the execution engine, state persistence, and human-in-the-loop checkpoints.

# pip install langgraph
from langgraph.graph import StateGraph, END
from typing import TypedDict, Annotated
import operator

# Define your shared state schema
class AgentState(TypedDict):
    messages: Annotated[list, operator.add]  # append-only list
    research: str
    draft: str
    status: str

Defining State in LangGraph

Every LangGraph workflow operates on a shared state object that all nodes can read and write. The state is a typed dictionary (TypedDict) that carries data through the graph. When a node runs, it receives the current state, performs its work, and returns a dictionary of updates to merge into the state. This shared-state model is what enables agents to communicate without direct coupling.

from typing import TypedDict

class ResearchState(TypedDict):
    query: str           # input from user
    research_notes: str  # filled by researcher node
    written_draft: str   # filled by writer node
    review_feedback: str # filled by reviewer node
    final_output: str    # filled by synthesizer node
    iteration_count: int # tracks how many revision loops occurred

# Each node returns a PARTIAL update - only the keys it modifies
def researcher_node(state: ResearchState) -> dict:
    notes = do_research(state['query'])
    return {'research_notes': notes}  # only update this key

All lessons in this course

  1. Why Single Agents Hit a Wall
  2. Orchestrator-Subagent Pattern
  3. Building Multi-Agent Pipelines with LangGraph
  4. Shared Memory and Inter-Agent Communication
← Back to AI Engineering Academy