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 in Python (No LangChain)
Rating: 2.0 out of 5(1 rating)
51 students

Build an AI Agent From Scratch in Python (No LangChain)

Build your own ~1,300-line agent framework in pure Python — tools, memory, planning, multi-agent, evals. No black boxes.
Created byAbhijoy Sarkar
Last updated 8/2026
English
English [Auto],

What you'll learn

  • Build a reusable agent loop — observe, decide, act, feed back, stop — with a correct stopping condition
  • Give an agent tools from scratch: parse tool calls, dispatch them, and handle a hallucinated tool without crashing
  • Implement working, episodic, and semantic memory — and write cosine similarity and top-k retrieval yourself from scratch
  • Make an agent reason with ReAct, reflection, and tree-of-thoughts, and route each task to the right strategy
  • Coordinate multiple agents with a delegation cap, evaluate them (success rate, cost, regressions), and harden for production with caps, logging, and guardrails

Coding Exercises

This course includes our updated coding exercises so you can practice your skills as you learn.

See a demo
Image of coding exercise example

Course content

9 sections • 49 lectures • 1h 41m total length
  • Course promise + what you'll build4:17
  • The definition: an LLM in a loop with tools1:52
  • Why LangChain/CrewAI hide this from you1:01
  • Build a working agent in 20 lines2:52

    Write a complete, working agent in about 20 lines of plain Python with no frameworks, using a five-part observe–decide–act loop and a final answer marker. Module 1 expands this into a reusable agent class with tools, memory, planning, and evaluation.

  • Knowledge check: What an agent actually is

Requirements

  • Solid Python: functions, classes, and dicts. You've called an LLM API at least once.
  • An API key for any OpenAI-compatible or Anthropic model (a few dollars of usage covers the labs).
  • No machine-learning math required — the one bit (a dot product) is taught from scratch. No LangChain, no vector DB.

Description

This course contains the use of artificial intelligence.

An AI agent is just an LLM in a loop that chooses its own next action. Once you can write that loop — about twenty lines of plain Python — every "agent framework" on the market stops being magic.


This course is the un-magic. You build your own agent framework from scratch, one concept at a time, and walk away understanding every line of it — and able to read LangChain, CrewAI, or AutoGen like an open book.


What you'll build, across nine short modules: the reusable agent loop with a correct stopping condition; tool use from scratch (parse, a registry and dispatch, and graceful handling when the model invents a tool); three kinds of memory — working, episodic, and semantic retrieval you build with your own cosine similarity in numpy; planning with ReAct, reflection-and-retry, and a real beam-search tree-of-thoughts; multi-agent systems with a coordinator and a delegation cap so it can never loop forever; evaluation — the part almost no course teaches — a harness, the three metrics that matter, a failure taxonomy, and regression diffs; production hardening with cost and step caps, structured logging, and tool guardrails; and a capstone that consolidates it into one clean API and builds a flagship agent end to end.


Honest about scope: "from scratch" means you build everything that turns a model into an agent. The one black box we keep is the language model and its embeddings, called through a thin wrapper. It's about 1,300 lines of pure Python — numpy and a provider client only. No LangChain, no vector database.


You need solid Python and to have called an LLM API once. You do not need any machine-learning math — the one bit, a dot product, is taught from scratch. By the end you won't just have working code; you'll have the judgment to design agents that don't burn money or fail silently, and you'll understand what every framework on the market is really doing.

Who this course is for:

  • Working developers who use LLMs but treat agents as magic and want first-principles mastery.
  • Engineers who've wired up LangChain or CrewAI without understanding what's underneath.
  • Builders who want to ship reliable agents — with evals, caps, and guardrails — not just demos.