๐Ÿ“‹ Learn AI Agents the school way

Chatbots answer; agents achieve. This school teaches the loop that makes the difference โ€” and ships it: a real agent in the repo, ~130 lines of pure Python, zero dependencies, no API key. Run it, drive it, break it, eval it, read every line.

๐Ÿ” thinkโ†’actโ†’observe๐Ÿงฐ tools & belts ๐Ÿ“” memory๐Ÿšง guardrails ๐Ÿ’ฅ failure modes๐Ÿ‘ฏ 5 patterns

๐Ÿ” Part 1 โ€” THE MACHINE (1โ€“5)

  • answers vs outcomes โ€” the doer with a hall pass ๐ŸŽซ
  • the loop: think โ†’ act โ†’ observe, on repeat
  • the belt: labels are half the intelligence ๐Ÿงฐ
  • the pad, the small desk โ€” and the field-trip rules ๐Ÿšง

๐Ÿ’ฅ Part 2 โ€” REALITY (6โ€“8)

  • five failure modes + the evals that catch them ๐Ÿ“Š
  • read the agent whole: 130 honest lines ๐Ÿ”ฌ
  • patterns: planners, critics, teams, human gates ๐Ÿ‘ฏ
  • โ€ฆand the rarest skill: knowing when NOT to ๐Ÿ™…
# the 60-second wow โ€” a goal becomes an outcome:
git clone https://github.com/BaluRaut/learn-agents-school.git && cd learn-agents-school
python3 agent/agent.py            # a scripted brain runs the picnic errand
python3 agent/agent.py --drive    # YOU are the brain: pick every action

๐Ÿ—บ๏ธ The big picture โ€” one diagram, both worlds

Click for the 4K version.

The big picture: the agent machine (loop, tools, memory, guardrails) and reality (failures, evals, patterns)

๐ŸŽ“ The 8 lessons

One git branch = one idea; branch 05 contains lessons 01โ€“05. Deep-dive companion to the AI course's lesson 11 โ€” and the MCP school supplies the tool belt. Curious how we got here and where it goes? Read before ยท why ยท agentic ยท future.

1

๐Ÿ“‹ What is an agent

Answers vs outcomes โ€” the reciter vs the doer with a hall pass.lesson-01-what-is-an-agentRead lesson โ†’See the diagram โ†—
2

๐Ÿ” The loop

Think โ†’ act โ†’ observe โ€” how you run errands, and how agents do.lesson-02-the-loopRead lesson โ†’See the diagram โ†—
3

๐Ÿงฐ Tools

The belt: labels are half the intelligence; reads flow, writes gate.lesson-03-toolsRead lesson โ†’See the diagram โ†—
4

๐Ÿ“” Memory

Scratchpad, the small desk, compaction โ€” and the homework diary.lesson-04-memoryRead lesson โ†’See the diagram โ†—
5

๐Ÿšง Guardrails

Field-trip rules: curfew, write gates, hardened tools, full logs.lesson-05-guardrailsRead lesson โ†’See the diagram โ†—
6

๐Ÿ’ฅ Failure modes

Confidently wrong, with momentum โ€” five ways it breaks, and evals.lesson-06-failuresRead lesson โ†’See the diagram โ†—
7

๐Ÿ”ฌ Build an agent

Read agent.py whole: 130 lines, every concept at a line number.lesson-07-build-an-agentRead lesson โ†’See the diagram โ†—
8

๐ŸŒ Agent patterns

Planners, critics, teams, human gates โ€” and when NOT to.lesson-08-patternsRead lesson โ†’See the diagram โ†—
๐Ÿ‘ฏ The showcase: 5 agent patterns โ€” solo doer, planner+executor, critic loop, human-in-the-loop, the team โ€” each with a numbered flow diagram AND a full sequence diagram.

๐Ÿ“ The lesson diagrams โ€” follow the numbers

Teal = the machine, red = reality. Lesson 02 is a sequence diagram โ€” the loop in its natural notation. Also on a standalone page.

1 ๐Ÿ“‹ What is an agent

Answers vs outcomes โ€” the reciter vs the doer with a hall pass.

๐Ÿ—ฃ๏ธ chatbot โ€” answers'how many pizzas?' โ†’'probably 6-8?' โ€” words,from memory, maybe wrong1๐Ÿ“‹ agent โ€” outcomes๐Ÿง  model in a LOOPthinkโ†’actโ†’observe๐Ÿงฐ tools + ๐ŸŽซ hall passlookup ยท calc ยท writeโœ… counted 23 kids, computed 8 pizzas,SAVED the plan โ€” the job is DONE2same brain โ€” the difference is the loop and the pass ยท run it: python3 agent/agent.py3

Read full lesson 01 โ†’

2 ๐Ÿ” The loop

Think โ†’ act โ†’ observe โ€” how you run errands, and how agents do.

๐Ÿง  brain๐Ÿซ harness๐ŸŒ worldthe THINK beat is next-token prediction; the loop is a conversation with realityTHINK ๐Ÿ’ญ 'need the class size' โ€” reasoning as text1ACT ๐Ÿงฐ lookup {"topic":"class 3A"}2executes the tool3'Class 3A has 12 students.'4OBSERVE ๐Ÿ‘€ โ†’ onto the scratchpad5๐Ÿ” repeat, smarter each beat โ€” until done {answer} (or MAX_STEPS ๐Ÿ•)

Read full lesson 02 โ†’

3 ๐Ÿงฐ Tools

The belt: labels are half the intelligence; reads flow, writes gate.

๐Ÿงฐ the belt (TOOLS)lookup โ€” READ ยท 'ask the office'calc โ€” READ ยท 'safe math'write_note โ€” WRITE ๐Ÿšง gated!1๐Ÿง  modelpicks by READING the labels โ€”labels are half the intelligence2๐Ÿซ harnessexecutes ยท gates writes ยทreturns observations3observation โ†’ the desknever eval() what a model wrote โ€” see _safe_eval: an allowlist, not trust ๐Ÿ”’

Read full lesson 03 โ†’

4 ๐Ÿ“” Memory

Scratchpad, the small desk, compaction โ€” and the homework diary.

๐Ÿช‘ the desk โ€” finite!๐Ÿ“‹ goal + to-do๐Ÿ“” scratchpad:[lookup 3A]โ†’12 kidsโ€ฆ๐Ÿ’ญ THINK reads all of it, every beat1๐Ÿ—œ๏ธ compaction10 jottings โ†’ 1 summary line, when the desk fills2๐Ÿ“ durable memory OUTSIDEwrite_note / files / DB / RAG over past runs3'it forgot step 3' and 'it falls apart after 30 steps' are BOTH desk problems โ€” now you know the fix first

Read full lesson 04 โ†’

5 ๐Ÿšง Guardrails

Field-trip rules: curfew, write gates, hardened tools, full logs.

๐Ÿ” the loop wants to run forever,touch everything, trust every input๐Ÿ• MAX_STEPS + budgetsbounded loops, bounded bills1๐Ÿšง write gates โ€” reads flow,writes wait for a human [y/N]2๐Ÿ”’ hardened tools + scoped credsallowlists, least privilege (AWS L03)3๐Ÿงพ full logs โ€” every beat,numbered, replayable4๐Ÿ“ฆ sandboxes โ€” blast radius= one container ๐Ÿฑ5

Read full lesson 05 โ†’

6 ๐Ÿ’ฅ Failure modes

Confidently wrong, with momentum โ€” five ways it breaks, and evals.

๐Ÿ’ฅ compounding: wrong fact at step 2โ†’ polished wrong answer at step 91๐Ÿ”„ loops: the same act,again and again and again2๐Ÿ“ injection: instructionshiding inside tool results3๐ŸŽฏ goal drift:'helpful' side quests4๐Ÿ™‹ fake done: declared success,no actual outcome5๐Ÿ“Š EVALS โ€” scored scenarios, run on every changeoutcome checks ยท step budgets ยท gate audits ยท a deterministic world to assert against

Read full lesson 06 โ†’

7 ๐Ÿ”ฌ Build an agent

Read agent.py whole: 130 lines, every concept at a line number.

1 ๐Ÿงฐ TOOLSthe belt: labels + writes-flags+ _safe_eval (hardened)SCHOOL_DB = a deterministicworld โ€” evals assert against it12 ๐Ÿง  BRAINS โ€” swappableScriptedBrain: toy plannerHumanBrain: --drive (you!)โ† ONE LLM call slots here;the harness never changes23 ๐Ÿ” run() โ€” the loopMAX_STEPS curfew ๐Ÿ•write gate ๐Ÿšง (one if!)errors-as-observationsscratchpad.append = memoryprints every beat ๐Ÿงพ3~130 lines, no framework โ€” every framework is this file with more adjectives

Read full lesson 07 โ†’

8 ๐ŸŒ Agent patterns

Planners, critics, teams, human gates โ€” and when NOT to.

๐Ÿ™… steps fixed?โ†’ a SCRIPT1๐Ÿ—ฃ๏ธ one answer?โ†’ one model call2๐Ÿง path varies by discovery?โ†’ SOLO agent + tools(start here!)3๐Ÿ—บ๏ธ long/structured? + planner๐Ÿง‘โ€๐Ÿซ quality-critical? + critic4๐Ÿšง irreversible steps? + human gates(always โ€” drafts flow, signatures gate)5๐Ÿ‘ฏ truly parallel? + a team โ€”with a foreman & checkable artifacts6every pattern = the same loop, wrapped โ€” the best architects say 'this doesn't need an agent' weekly ๐Ÿ™…

Read full lesson 08 โ†’

Start Lesson 01 โ†’ ๐Ÿ‘ฏ The 5 patterns โฎ๏ธ Before ยท why ยท agentic ยท future ๐Ÿ“ All 8 lesson diagrams ๐Ÿงช Quiz ๐Ÿ—“๏ธ Study plan ๐Ÿ”Œ The MCP school