Skip to content
derpx06.dev
WritingExplainersNotesAbout
works on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisationworks on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisation

Learning in public.

A student's notebook on system design, distributed systems and databases. Shared as I learn.

ReadWritingExplainersNotesAbout
ElsewhereGitHubLinkedInHugging FaceLeetCode
Say hellomanaskhairnar1511@gmail.com
derpx06
NORMALmain© 2026 Derpx06Pune, Indiatop ↑
Learn/LangChain Mastery/Part 8 · 7. Tools & Agents
Lesson 59 of 68

LangGraph: Stateful Agents

Beyond the loop. Why ReAct hits a glass ceiling.

Derpx0610 Jan · 1 min read
LangChain Mastery
Designing Tool SchemasFunction Calling in LangChainTool Selection & ValidationReAct AgentsPlan-and-Solve AgentsFallbacks & Error HandlingLangGraph: Stateful AgentsHuman-in-the-Loop
Contents
1. The Limit of Loops2. Nodes and Edges3. State as First-Class Citizen4. Why This Wins5. Summary
0% read · 1 min leftBack to top ↑
Course outline & contents0%
LangChain Mastery
Designing Tool SchemasFunction Calling in LangChainTool Selection & ValidationReAct AgentsPlan-and-Solve AgentsFallbacks & Error HandlingLangGraph: Stateful AgentsHuman-in-the-Loop
Contents
1. The Limit of Loops2. Nodes and Edges3. State as First-Class Citizen4. Why This Wins5. Summary

1. The Limit of Loops

ReAct is a while loop. while not done: act() This works for "Search Google," but it fails for "Write Code -> Test -> Fix -> Deploy." That requires a state machine. It requires Directed Graphs.

2. Nodes and Edges

LangGraph treats your agent as a graph.

  • Nodes: Functions that do work (e.g., AgentNode, ToolNode, HumanNode).
  • Edges: Logic that decides where to go next (e.g., if tool_called: go_to_tools else: end).

3. State as First-Class Citizen

In LangChain chains, state is often implicit (hidden in memory buffers). In LangGraph, you define a explicit StateSchema.

Python
class AgentState(TypedDict):
    input: str
    chat_history: list[BaseMessage]
    agent_outcome: str | None
    intermediate_steps: list[tuple[AgentAction, str]]

Every node receives this State, modifies it, and passes it to the next node. It is Functional Programming applied to Agents.

4. Why This Wins

  1. Cyclic Graphs: You can code explicit loops. Code -> Test -> Fail? -> Fix Code -> Test.
  2. Persistence: You can pause the graph at any node, save specific state to a database, and resume days later.
  3. Human-in-the-Loop: A "Node" can be "Wait for User Approval." The graph literally sleeps until the API receives a POST request.

5. Summary

For simple chatbots, use ReAct. For complex workflows (Coding Assistants, Research Teams), use LangGraph. Structure beats prompt engineering every time.

Key Intuition: "Draw the flowchart. That is your Agent."

Track your progressSign in and your progress follows you across devices.
Sign in to track progress Next lesson
← Previous lessonFallbacks & Error HandlingNext lesson →Human-in-the-Loop