Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Build an AI Agent from Scratch with LangGraph
New
7 students

Build an AI Agent from Scratch with LangGraph

Build an on-call AI agent by hand in Python, trace and score it, then rebuild it line by line in LangGraph
Created byThanh Vũ
Last updated 11/2026
English
English

What you'll learn

  • Call an LLM API with raw HTTP and the SDK, and count tokens, cost and latency by hand
  • Get validated structured output from a model with JSON schema, Pydantic and retry
  • Write your own LLM client with retries, backoff and a record-replay cache
  • Design tool schemas, run single and parallel tool calls, and recover from bad arguments
  • Write a ReAct agent loop in plain Python with stop conditions for answer, steps and budget
  • Trace an agent run and debug a looping agent from its trace
  • Score an agent on incidents with exact and rule-based graders
  • Rebuild the same agent in LangGraph with StateGraph, reducers, conditional edges and create_agent
  • Show that two versions of an agent take the same steps and get the same score

Course content

9 sections • 33 lectures • 6h 39m total length
  • 0.1 Watch Nightwatch fix a 3 a.m. incident3:16
  • 0.2 Setup in 10 minutes - uv, a free Groq key, replay mode9:11
  • 0.3 How every lesson works, and a fast lane3:09

Requirements

  • Python basics: functions, lists and dictionaries
  • A computer that runs Python 3.13 (uv installs it for you in lesson 0.2)
  • No API key needed to follow along; a free Groq key is optional for live calls
  • No prior experience with LLMs, agents or LangGraph

Description

This course contains the use of artificial intelligence.

Most agent tutorials start with one framework call. When the agent loops forever or answers from the wrong data, you are left guessing what happened inside. In this course you build the agent yourself first, trace it, score it, and only then rebuild it in LangGraph, line by line, so every node and edge has something you already understand behind it.

The course is being rebuilt in waves. Two waves are live: chapters 0 to 5 and 9 to 11, 33 videos, about 6.6 hours. Wave 2 added MCP, human approval, evals you can trust and prompt-injection defense. The next waves add retrieval, memory, deep agents, self-improving agents and a capstone.

What you build in the new chapters

  • Nightwatch, an on-call agent that investigates incidents in Brightcart, a simulated online shop with 60 incidents.
  • Your own LLM client: raw HTTP, tokens and cost by hand, structured output with validation and retry, retries with backoff, a record-replay cache.
  • Tool calling by hand: schemas, parallel calls, bad arguments and recovery.
  • The ReAct loop in about 40 lines, stop conditions, your own tracer, and a real debugging session on a looping agent.
  • A score: Nightwatch v0 graded on incidents with exact and rule graders.
  • The same agent in LangGraph: state, nodes, edges, reducers, conditional edges, create_agent with middleware, and a check that both versions take the same steps and get the same score.
  • MCP: the protocol on the wire, your own MCP server with contract tests, and pinned descriptions for servers you did not write.
  • Human approval: pause before every write with interrupt, resume in a new process, approve, edit or reject, plus retries and timeouts per node.
  • Evals you can trust: pass@k, pass^k, paired bootstrap intervals, and a pytest gate that replays saved runs for zero tokens.
  • Security: measure prompt injection through logs and tool output, then defend against an attacker who rewrites the payload.

How every lesson works

  • Theory with small hand calculations, then live coding in VS Code, then the takeaways.
  • Every number on screen comes from real runs on open models served by Groq.
  • A notebook for every lesson. Notebooks run in replay mode with no API key; a free Groq key lets you make live calls.
  • A quiz for every chapter (114 questions). Every answer explains why it is right or wrong.

All code is in a public GitHub repo named build-ai-agent-from-scratch. Lesson 0.2 sets it up in about ten minutes.

Narration uses an AI-synthesized voice. Brightcart, its incidents and Nightwatch are made up for this course.

Who this course is for:

  • Python developers who want to see what happens inside an AI agent
  • Engineers who used agent frameworks and want to debug them with confidence
  • Data scientists moving from notebooks to LLM applications
  • Students preparing for AI engineer roles