Video summary
LangGraph Complete Course for Beginners – Complex AI Agents with Python
Main summary
Key takeaways
Course overview (LangGraph + Python)
- The instructor (Vava/Vbeca, a robotics & AI student) teaches LangGraph, a Python library for building conversational AI workflows using a graph-based approach (nodes + edges).
- The course focuses on beginner-friendly, step-by-step development:
- theory first,
- then coding,
- then progressively more capable “agentic” systems.
- Exercises are included throughout; answers are provided on GitHub.
Part 1: Type annotations (theory needed before coding)
Introduces several Python typing concepts and explains how they relate to LangGraph—especially defining state structures:
-
Typed dictionaries (type dictionaries / dataclass-like structure): Used to define LangGraph states with explicit key/value types for:
- type safety,
- fewer logical/runtime errors,
- better debugging.
- Union: restricts a value to one of multiple allowed types.
- Optional: a value can be a type or
None. - Any: accepts any type.
- Lambda: shorthand for small functions (example: using
mapto square values).
Part 2: Core LangGraph elements (dataflow model)
Defines the foundational building blocks:
- State: shared application “memory” that nodes read/write.
- Nodes: individual functions/operations. Each node:
- receives input (often the current state),
- processes it,
- returns an updated state.
- Graph: overall workflow structure (execution + conditional structure).
- Edges: connections controlling which node runs next.
- Conditional edges: the next node is selected based on logic/conditions in state.
- Start node / End node: virtual entry/exit points.
- Tools: specialized utilities nodes can call (e.g., API calls).
- Tool node: a special node that executes tools and writes tool results back into state.
- Runnable concept: standard executable component in LangGraph (compared to nodes as higher-level modular operations).
- Message types: examples include:
- HumanMessage
- AIMessage
- SystemMessage
- ToolMessage
- FunctionMessage
Part 3: Coding graphs (incremental tutorials + exercises)
Graph 1 — “Hello World” (single node)
- Builds a minimal StateGraph with:
- typed state containing
message: str - a node that appends a greeting to
state["message"] - an entry point and finish point wired to the node
- use of
compile()andinvoke()to run
- typed state containing
- Includes an exercise: build a personalized compliment agent that concatenates to existing state.
Graph 2 — Multiple inputs + one node
- State schema expanded to include different types:
values: list[int],name: str,result: str
- Node logic:
- sums the integer list (
sum(state["values"])) - concatenates into
state["result"]
- sums the integer list (
- Demonstrates:
- invoking the compiled graph,
- accessing outputs cleanly (e.g.,
output["result"]), - printing state before/after the node.
- Exercise: add an operation selector (
+sum vs*multiply), handled in one node using an if-statement.
Graph 3 — Sequential graph (multiple nodes + edges)
- Adds a two-node sequence:
- Node 1 writes a greeting into
final - Node 2 appends age-based text into the same
final
- Node 1 writes a greeting into
- Highlights a common logical error:
- replacing
state["final"]instead of concatenating to preserve earlier content.
- replacing
- Learns to connect nodes using edges (
graph.add_edge(start, end)). - Exercise: extend to three nodes:
- greeting name,
- describe age,
- list skills into formatted output,
- combine into
result.
Graph 4 — Conditional graph (routing based on state)
- Introduces routing via conditional edges:
- state includes
number_1,operation(+or-),number_2,final_number - router node returns an edge key (“addition operation” vs “subtraction operation”)
- state includes
- Uses a lambda pass-through when the router doesn’t update state (router returns an edge key rather than state).
- Compiles a graph with:
- start → router,
- conditional edge selects add vs subtract node,
- both converge to end.
- Exercise: “monstrosity” version:
- handle two pairs of numbers with their own operations,
- output both final results.
- Reinforces understanding of conditional edge routing.
Graph 5 — Looping graph
- Teaches looping using conditional edges that decide continue vs exit.
- Example implemented:
- greeting node sets
nameand resetscounter - random node generates random numbers and increments counter
- conditional function loops back until 5 numbers are collected
- greeting node sets
- Exercise: implement an automatic higher/lower game:
- guesses a number between 1–20,
- uses “higher/lower” hints to adjust bounds,
- maximum of 7 attempts,
- no human-in-the-loop (the graph self-iterates).
Part 4: AI agents (LLM integration + memory + tools + projects)
Agent 1 — “Simple bot” (LLM wrapper inside a graph)
- Builds an LLM-backed graph with:
- state containing
messages: list[HumanMessage] - a node calling ChatOpenAI (GPT-4o) via
invoke
- state containing
- Demonstrates:
- interactive loop (a
whileloop outside the graph), - no memory inside the graph (each run is stateless).
- interactive loop (a
Agent 2 — Chatbot with memory + persistence
- Adds message history using:
messages: list[HumanMessage | AIMessage]via Union
- Node:
- calls the LLM with the full conversation history
- appends AI responses back into
state.messages
- Highlights problems + solutions:
- Memory resets each program run → fix by writing conversation history to a text log file.
- Token growth cost (history grows unbounded) → suggest trimming (e.g., keep only last N human messages).
- Implements logging by iterating over conversation history and writing human/AI content separately.
Agent 3 — ReAct agent (Reasoning + Acting with tools)
- Implements a ReAct-style loop:
- the LLM decides whether to call tools,
- the tool node executes,
- the loop continues until no more tool calls.
- Key LangGraph concepts used:
- Tool messages and system messages
Annotated[..., add_messages]reducer so state updates append rather than overwrite- decorated tools (example:
add(a, b)) - conditional edge: checks the last message for tool calls to decide continue vs end
- tool → agent edge for the loop
- Demonstrates:
- math queries that trigger tool calls,
- multi-step tool calling (e.g., add then multiply),
- robustness even when tools aren’t needed (LLM answers directly).
Agent 4 — “Drafter” project (human-AI collaboration)
- Mini-project: AI drafting agent supporting iterative human feedback and stopping when the user is satisfied.
- Graph design:
- agent node uses tools via tool node
- two tools:
- update tool: updates a draft document content buffer
- save tool: saves draft to a
.txtfile and ends the process
- conditional logic after tools:
- if last tool used was
update→ continue loop - if last tool used was
save→ end graph
- if last tool used was
- Uses a workaround with a global variable to store current document content for tools (mentions injected state concept but keeps it simple).
- Demo flow:
- user provides requested email/document content,
- agent iteratively updates,
- user triggers
save, - system writes file with generated filename.
Agent 5 — RAG agent (Retrieval-Augmented Generation)
- Builds a two-agent graph:
- Retriever agent: tool searches a vector database for relevant PDF chunks.
- LLM agent: answers using retrieved context, with citations.
- Pipeline implemented:
- load PDF (stock market performance document)
- chunking:
- chunk size (e.g., 1000 tokens)
- overlap (e.g., 200 tokens)
- embeddings + Chroma vector database
- retriever tool returns top-k similar chunks (k≈5)
- Conditional loop:
- continues while there are tool calls; ends when no tool calls remain.
- Test outcomes:
- answers include evidence and citations from the PDF (validated by matching expected figures),
- avoids hallucinating when information isn’t in the document (e.g., OpenAI stock performance).
Main speakers / sources
- Speaker / Instructor: Vava (also referenced as Vbeca in the subtitles).
Rate this summary
Your feedback will help improve summaries.
Improve this summary
Reprocess with a stronger model when the summary feels incomplete or inaccurate.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.