Vol. 14.3 LangGraph introduced graphs for RAG critique loops (retrieve → generate → revise). This lecture is the agent control plane: typed state as working memory, tool nodes, conditional routing, checkpointers, and HITL interrupts. Read 14.3 for graph ABCs; use this page for production agent patterns.
LangChain still supplies tools and models. CrewAI / AutoGen hide topology behind roles or chats—LangGraph makes topology explicit.
Learning Objectives
By the end of this lesson, students should be able to:
- Model an agent as a state graph: nodes, edges, reducers, cycles.
- Implement a tool-calling node with routing back to the model or END.
- Use interrupts + checkpointers for HITL pause/resume.
- Distinguish graph state (WM / in-flight) from organizational LTM.
- Contrast LangGraph vs LangChain executors vs multi-agent chat frameworks.
- Design small, named subgraphs instead of one giant mega-graph.
LangGraph (agent view) is a library for durable, stateful multi-actor LLM apps. You declare a shared state schema and a graph of steps—including cycles—so the agent loop is visible, interruptible, and resumable rather than buried in an executor.
From Hidden Loop to Explicit Graph
| Concern | LangChain agent executor | LangGraph agent |
|---|---|---|
| Control flow | Opaque while-loop | Nodes + conditional edges |
| State | Message list soup | Typed fields + reducers |
| HITL | DIY callbacks | interrupt / resume + checkpoint |
| Failure recovery | Restart the whole run | Resume from last checkpoint |
| Multi-actor | Awkward | Multiple nodes / subgraphs |
Agent Graph Pattern
agent (model)
- Reads state.messages
- May emit tool_calls
- Or returns final text
tools
- Executes calls (MCP OK)
- Writes observations
- Edges back to agent
human
- interrupt() before writes
- Approval in state
- Resume with checkpoint
Tool Loop + HITL Sketch
Vol. 14.3 sketched retrieve → generate. Here the cycle is model ↔ tools, with an optional human gate on dangerous tools—the Volume 15 pattern.
State vs Long-Term Memory
Checkpoints snapshot in-flight working memory so HITL can resume. They are not the company wiki. After success, commit recaps to episodic LTM and keep policies in the vector store. Mixing checkpoint blobs into semantic search is a design smell.
Pick LangGraph when
- HITL, retries, or long-running jobs
- You need inspectable topology
- Shared state across specialist nodes
- Compliance requires replay
Tradeoffs
- More upfront design than LC agents
- Easy to over-graph simple Q&A
- Reducer bugs = silent state corruption
- Not a role-play UX (CrewAI) or chat UX (AutoGen)
“If I compile a graph, I automatically have multi-agent collaboration.” Multiple nodes can still be one logical agent. Multi-agent means distinct roles, permissions, and (often) subgraphs—see multi-agent systems. A giant node named do_all is still a single-agent loop with extra ceremony.
Knowledge Check
- Short Answer: What does LangGraph make explicit that LC agent executors hide? Answer: The loop as nodes/edges plus typed durable state.
- True/False: Vol. 14.3 LangGraph was mainly a RAG critique-loop intro. Answer: True—this lecture is the agent/HITL control plane.
- Multiple Choice: interrupt() is for: (a) CNN dropout, (b) HITL pause/resume, (c) MCP stdio only. Answer: (b).
- Short Answer: Is a checkpointer organizational LTM? Answer: No—it snapshots in-flight working memory for a thread.
- True/False: Dangerous tools should route through a human node. Answer: True.
- Multiple Choice: After tools run, the edge typically returns to: (a) agent, (b) PCA, (c) volume 07. Answer: (a).
- Short Answer: Name one reducer use in AgentState. Answer: messages: Annotated[list, operator.add] to append rather than overwrite.
- True/False: LangGraph replaces the need for MCP servers. Answer: False—tool nodes can call MCP; graphs do not implement I/O catalogs.
- Multiple Choice: Prefer a plain LCEL RAG chain when: (a) simple Q&A, (b) multi-day HITL ops, (c) group chat debate. Answer: (a).
- Short Answer: Which next framework specializes in data/index agents? Answer: LlamaIndex.
Key Takeaways
- LangGraph is the inspectable, durable agent loop—not just a RAG graph toy.
- Typed state = working memory; checkpoints ≠ semantic LTM.
- HITL interrupts belong on write paths; tool nodes can wrap MCP.
- Use graphs when topology matters; keep Vol. 14.3 chains for linear RAG.
- Continue with LlamaIndex.
Lab: Implement agent ↔ tools with a fake interrupt on create_jira_comment; resume approved vs denied and compare traces.
Whiteboard: Draw Vol. 14.3 critique graph vs this HITL tool graph. Mark thread_id vs episode LTM write after END.
Recap: LangGraph is the agent control plane. Continue with LlamaIndex.