Module 1: Why Graphs for Agents

What Is LangGraph

Learning objectives

  • Explain the core mental model behind What Is LangGraph
  • Apply What Is LangGraph within Why Graphs for Agents
  • Identify important boundaries, trade-offs, and failure modes
  • Produce concrete evidence from the practice exercise

Related: LangGraph Why It Exists | LangGraph Core Concepts | LangGraph Architecture Overview | LangGraph Index


A Working Definition

LangGraph is a library for building stateful, multi-agent applications as graphs. It extends LangChain with a graph-based execution model where nodes represent functions, edges represent transitions, and state is a shared, typed data structure that evolves as the graph executes.

A precise one-line definition:

LangGraph turns an agent workflow into a deterministic state machine with cycles.

That definition has four operative words:

Graph. The application is a directed graph. You define nodes and edges explicitly. Unlike a chain, the graph can loop back on itself.

Stateful. Every step reads from and writes to a central State object. State is persistent across turns, not just prompt context.

Multi-agent. Multiple agents can be nodes in the same graph, sharing state and communicating via structured handoffs.

Cycles. The graph can loop. This is the key difference from DAG-based workflow engines. Cycles enable agent loops, retry logic, and human-in-the-loop approvals.


LangGraph vs LangChain Chains

A LangChain chain:

chain = prompt | model | parser
result = chain.invoke(input)

A LangGraph graph:

builder = StateGraph(State)
builder.add_node("agent", agent_node)
builder.add_node("tool", tool_node)
builder.add_edge(START, "agent")
builder.add_conditional_edges("agent", should_continue, {True: "tool", False: END})
builder.add_edge("tool", "agent")
graph = builder.compile()
result = graph.invoke({"input": "What is RAG?"})

The difference is not just syntax. The graph:

  • Has explicit state that survives across nodes
  • Can cycle (agent → tool → agent → tool → ...)
  • Supports branching and conditional routing
  • Can pause for human input mid-flight

LangGraph vs Other Frameworks

FrameworkCenter of gravityMental model
LangChain chainsLinear pipelines"I am piping data through functions"
LangGraphCyclic state machines"I am building a graph that evolves state"
CrewAIRole-based agents"I am hiring a team"
Temporal / AirflowDAG workflows"I am scheduling tasks"
Hermes / OpenClawAgent runtime"I am running an agent loop"

LangGraph is closest to a workflow engine, but with cycles. It is not as opinionated as CrewAI (no fixed roles) and not as free-form as a pure agent runtime.


Philosophy

Explicit Over Implicit

In LangGraph, you define every node and edge. There is no hidden agent loop. This makes behavior predictable and debuggable.

State as the Source of Truth

All communication happens through the shared state object. Nodes do not call each other directly; they read state, do work, and write state.

Human-in-the-Loop First

LangGraph has first-class support for interrupts: the graph can pause at any node, wait for human input, and resume. This is not an afterthought; it is a primitive.


What LangGraph Is Not

  • Not a replacement for LangChain. It builds on LangChain. You still use LangChain models, prompts, and tools inside LangGraph nodes.
  • Not a no-code tool. You write Python to define graphs.
  • Not a general-purpose workflow engine. It is optimized for LLM-agent workflows, not ETL pipelines.
  • Not magic. Every step is a Python function call. The graph is a state machine, not a neural network.

A One-Sentence Mental Model to Carry Forward

A LangGraph application is a state machine where nodes are Python functions, edges are transitions conditioned on state, and the graph runs until it hits an end node or an interrupt.

Everything else — multi-agent, persistence, streaming — is a refinement of that model.

See LangGraph State Graph for the deep dive.


Related

  • LangGraph Why It Exists — the problems that motivate the library
  • LangGraph Core Concepts — the vocabulary used everywhere else
  • LangGraph Architecture Overview — the block diagram of the runtime
  • LangGraph State Graph — building your first graph
  • LangGraph Index — full topic map

Practice lab

Implement the smallest runnable agent workflow that demonstrates What Is LangGraph. Trace inputs, state, model and tool calls, outputs, and cost; inject one failure and add a regression test that prevents it from returning.

Review questions

  1. What problem does What Is LangGraph solve, and what assumptions does it rely on?
  2. Which boundary or failure case is easiest to miss, and how would you expose it?
  3. What alternative design would you consider, and what trade-off would change the decision?
  4. What artifact, trace, test, or metric proves that your implementation is correct?

Completion evidence

  • A working artifact, annotated trace, or reproducible experiment
  • At least one normal case and one deliberately failing or boundary case
  • A concise explanation of the design choice and its trade-offs
  • Saved output showing how correctness was evaluated