Volume 14.3 taught LangChain as RAG orchestration—LCEL chains, retrievers, linear Q&A. Do not retake that lecture. Here LangChain is the agent toolkit: bind tools, run a ReAct / tool-calling loop, attach working and long-term memory, and optionally call MCP tools.
When the loop needs durable state, HITL interrupts, or explicit branches, graduate to LangGraph (and its Vol. 14.3 counterpart). For multi-role crews, see CrewAI and AutoGen.
Learning Objectives
By the end of this lesson, students should be able to:
- Contrast LangChain chains (Vol. 14.3) with LangChain agents (this lecture).
- Describe the tool-calling / ReAct loop: reason → act → observe → repeat.
- Wire tools (including MCP-shaped ones) into a LangChain agent.
- Place chat history vs retrievers vs episode stores in the 15.2 memory model.
- Know when to stay on LangChain agents vs move to LangGraph.
- Set iteration caps, HITL hooks, and tracing for production loops.
A LangChain agent is a runnable that lets an LLM choose tools in a loop until it can answer or hits a stop condition. Unlike an LCEL RAG chain (retrieve → prompt → generate once), the control flow is model-directed: each step may call a tool, read the observation, and continue—the agent loop from Module 15.1, with LangChain glue.
Vol. 14.3 vs Vol. 15.4 — Same Product, Different Job
| Vol. 14.3 LangChain | This lecture (agents) | |
|---|---|---|
| Control flow | Mostly linear LCEL DAG | Cyclic tool loop (ReAct / tool-calling) |
| Primary I/O | Retriever + prompt | Tools + observations (+ optional retrieve) |
| Memory | Chain “memory” for chat RAG | WM scratch + LTM/episodes as tools |
| Stop condition | Chain returns | Final answer, max steps, or HITL |
| Next upgrade | LangGraph for RAG critique loops | LangGraph for durable agent graphs |
ReAct vs Native Tool Calling
ReAct (text)
- Thought / Action / Observation
- Works with weaker tool APIs
- Parse-fragile; verbose WM
Tool calling (API)
- Vendor function-call fields
- Preferred default today
- Matches MCP ↔ LLM schemas
When to graph
- Retries, branches, HITL pause
- Multi-actor shared state
- Use LangGraph
Minimal Tool-Calling Agent
API names shift across LangChain versions (create_tool_calling_agent, create_agent, etc.). Learn the pattern: tools with schemas, a model that can call them, a loop executor, a hard step limit.
Memory Wiring (15.2 Recap in LangChain)
Chat message lists are working memory—compact them. Retrievers are long-term semantic stores (Vol. 14 RAG). Episode tools are long-term episodic. Do not dump the full thread into every tool. For checkpoints and interrupts, do not stretch LangChain agents; use LangGraph.
Pick LangChain agents when
- Single actor, short tool loops
- You already live in LCEL / LC tools
- MCP or vendor tools just need a loop
- Prototype before a full graph
Move on when
- HITL pause/resume is required
- Branchy workflows or multi-agent
- You need typed durable state
- Hidden loops are undebuggable
“LangChain agents replace LangGraph.” Classic agents hide the loop inside an executor. LangGraph makes the loop a graph you can inspect, interrupt, and checkpoint. Vol. 14.3 already warned that serious cyclic agents belong on graphs; Volume 15 is where that warning becomes the default architecture for production HITL systems.
Knowledge Check
- Short Answer: How does a LangChain agent differ from a Vol. 14.3 RAG chain? Answer: The agent runs a model-directed tool loop; the chain is mostly linear retrieve→generate.
- True/False: This lecture is a repeat of LCEL RAG orchestration. Answer: False—it is the agent/tool-loop angle.
- Multiple Choice: ReAct traces are primarily: (a) working memory, (b) GPU kernels, (c) MCP transports. Answer: (a).
- Short Answer: Name two stop conditions for a tool loop. Answer: Final answer (no tool calls) and max steps / HITL abort.
- True/False: A vector retriever tool is long-term semantic memory. Answer: True.
- Multiple Choice: Durable HITL interrupts are best in: (a) unbounded LC agent executor, (b) LangGraph, (c) pooling layers. Answer: (b).
- Short Answer: How do MCP tools show up in a LangChain agent? Answer: Client maps tools/list to LLM tool schemas; loop calls tools/call.
- True/False: Native tool calling is generally more robust than parsed ReAct text. Answer: True.
- Multiple Choice: episode_lookup is: (a) semantic wiki, (b) episodic recall, (c) stdio transport. Answer: (b).
- Short Answer: Which next lecture is the agent control plane? Answer: LangGraph.
Key Takeaways
- Vol. 14.3 = chains/RAG; Vol. 15.4 = tool-calling / ReAct agents.
- Bind tools (semantic, episodic, MCP) and cap the loop.
- Chat history is working memory—compact it.
- Graduate to LangGraph for state, HITL, and inspectable cycles.
- Continue with LangGraph.
Lab: Run the three-tool sketch; force max_steps=2 vs 8 and discuss incomplete work vs runaway cost. Optionally swap lookup_ticket for a fake MCP client.invoke.
Whiteboard: Side-by-side Vol. 14.3 LCEL RAG vs this loop. Circle the upgrade path to LangGraph interrupts.
Recap: LangChain agents are tool loops, not RAG chains. Continue with LangGraph.