Chapter 5

LangChain & LangGraph

Compare first, then build + memory

Scroll: course-full-framework.html

Selection

Five options

Raw SDK · LangChain · LangGraph · CrewAI · OpenClaw

Selection

LangChain vs LangGraph

LCLG
Linear chainGraph + cycles
DIY loopSqliteSaver
LangChain

RAG chain

retriever | prompt | llm | parser
LangChain

RAG code

rag_chain = (
  {"context": retriever, "question": RunnablePassthrough()}
  | prompt | llm | StrOutputParser()
)
rag_chain.invoke("Refund window?")
LangGraph

ReAct graph

StateGraph · ToolNode · conditional_edges

LangGraph

Graph code

g = StateGraph(AgentState)
g.add_node("agent", call_model)
g.add_node("tools", ToolNode([search_docs]))
g.add_conditional_edges("agent", tools_condition)
app = g.compile(checkpointer=SqliteSaver(...))
LangGraph

Human-in-loop

interrupt_before=["tools"]

Memory

SqliteSaver

cfg = {"configurable": {"thread_id": "u1"}}
app.invoke({"messages": [...]}, cfg)
# same thread_id later → remembers ORD-99
LangGraph

Intent router

conditional_edges(START, route_intent)

order → order_agent · else → rag_agent

Memory

Checkpoint vs Store

CheckpointStore
Keythread_idnamespace
New chat?LostRecalled
Lab

Support agent lab

  1. LangChain RAG baseline
  2. LangGraph + tools
  3. SqliteSaver same thread
  4. Store cross-thread
  5. interrupt_before refund

Scroll: #lab + full code

Chapter 5 done

Scroll lab: course-full-framework.html#lab

Next: ⑥ MCP & A2A

Intro
1 / 1 Hub Space F