learn-ai-agents-with-phoebe / Builder session 1 of 10
Learn AI Agents with Phoebe · Builder track · Session 1 of 10

The agent loop

An agent is not a smarter chatbot - it is an LLM running in a loop with tools, deciding its own next step until the task is done. Tonight you learn the loop cold: what qualifies as an agent (and what does not), the four levers that make one reliable, and why most "agent failures" are really a missing lever. You will watch a real agent succeed and fail, step by step, in your browser - over Daybreak, the coffee brand whose MCP server you may have built in the MCP course. By b10 that server powers a full ops agent you assemble yourself.

🟢 Builder track Practitioners: DE · DS · AI engineers · builders Python · Claude API + Ollama path Start here
0-3 · Welcome 3-18 · What an agent is + the loop 18-42 · Build-along: watch it run + fail 42-45 · Q&A
Part 0

How this track works

Ten sessions, one running project: the Daybreak Ops Agent - an agent that answers and acts on a coffee brand's real operations questions, using its MCP server as a toolbox. Tonight you learn the loop. b2 wires tools, b3 builds the five workflow patterns, b4 adds memory, b5 planning, b6 goes multi-agent, b7 guardrails, b8 evals, b9 ships it, b10 assembles everything into the full agent and scores it. Every session ships a working artifact.

Live - presented in session Self-study - read after class ▶ Live agent run - step through + toggle levers Official sources covered
★ What you walk out with today A working definition of "agent" you can defend (with the official Anthropic and OpenAI wording), the loop drawn from memory, the four levers - tools, memory, planning, guardrails - and the habit this whole course is built on: when an agent fails, name the missing lever before touching the prompt.
Part 1 · covers Anthropic "Building Effective Agents", OpenAI guide pp.4-7, Ng M1

What an agent actually is 7 min live

Both vendors who defined the field agree. OpenAI: agents are "systems that independently accomplish tasks on your behalf." Anthropic: agents are systems where "LLMs dynamically direct their own processes and tool usage." The key word in both is direct - the model chooses the next step. An app where your code chooses every step is a workflow. Both are useful; only one is an agent.

USER GOAL "why the March dip?" MODEL decides next step: answer or act? TOOL runs query_sales("2026-03") RESULT observed "$150, 1 refund..." ANSWER when done the LOOP: model → tool → observe → model, as many turns as the task needs Exit conditions (OpenAI guide): a final-output answer · no more tool calls · an error · or max turns hit. Loops need exits. Not agents (by OpenAI's own exclusion): single-turn chatbots, sentiment classifiers - LLMs that never control what happens next.
🔍 Click to zoom - the loop that defines an agent, with its exit conditions
LiveThree components, four levers4 min▶

OpenAI's guide says every agent is three things: a model (the reasoning engine), tools (what it can touch), and instructions (the guidelines and guardrails it runs under). This course stretches that into the four levers you will toggle all night - because they are the four ways real agents fail:

  • Tools - without them the model answers from memory: fluent, confident, wrong.
  • Memory - without it, findings and instructions fall out of context mid-task.
  • Planning - without it, complex tasks get one-shot, half-done answers.
  • Guardrails - without them, the agent acts on things no one approved - including instructions hiding inside the data it reads.
Real world

The demo that lied. A team demoed an "analytics agent" to their exec - it answered every revenue question instantly and got a budget. In production someone checked a number against the warehouse: the agent had no database tool wired in and had been improvising figures the whole time. Nobody had asked which lever was on. You will run exactly this failure, on purpose, in Demo 1.

Self-studyWhen NOT to build an agent3 min read▶

OpenAI's guide is blunt: agents cost latency, money, and predictability - only reach for one when at least one of these holds:

  • Complex decision-making - judgment calls a rulebook cannot capture (refund approvals with context).
  • Difficult-to-maintain rules - the if/else forest nobody dares touch (vendor security reviews).
  • Heavy unstructured data - the task swims in documents and conversations (claim processing).

None of the three? Write deterministic code. Anthropic's essay opens with the same warning: the most successful agent builders use "simple, composable patterns" and add autonomy only when it demonstrably wins. "We could use an agent" is not a reason to.

Part 2 · covers HF Unit 1 (Thought-Action-Observation), Academy "Agents and workflows"

Inside one turn of the loop 6 min live

Hugging Face teaches the loop's inner beat as Thought → Action → Observation. The model reasons about where it is (thought), emits a structured tool call (action), and the runtime feeds the result back into context (observation). Then the cycle repeats - with one more observation in context each time. That growing context IS the agent's working state: protect it, and you have protected the agent.

1 · THOUGHT "I need February first" 2 · ACTION query_sales("2026-02") 3 · OBSERVATION "$271, 7 orders" CONTEXT WINDOW - the agent's only working memory goal + every thought, action and observation so far, in order next thought reads the whole history Every failure you will see tonight is a corruption of this picture: no actions (tools off), history lost (memory off), one turn only (planning off), wrong master (guardrails off).
🔍 Click to zoom - Thought, Action, Observation - and the context window that carries them
LiveWhere the four levers live in real stacks4 min▶

The levers are not this course's invention - they are what every serious framework ships, under different names. Learn the lever, and every framework becomes familiar:

  • Tools - Anthropic tool use / MCP servers · OpenAI function tools · HF "Tools". b2 wires Daybreak's MCP server in as the toolbox.
  • Memory - OpenAI SDK "Sessions" · LangGraph checkpointing + Store · Anthropic context management. b4.
  • Planning - Ng's Planning pattern · Anthropic's "transparency: show planning steps" principle. b5.
  • Guardrails - OpenAI's 7 guardrail types + human-in-the-loop · Agent SDK permission modes · LangGraph interrupts. b7.
Self-studyWorkflows vs agents is a dial, not a war3 min read▶

Anthropic's essay draws the line precisely: workflows orchestrate LLMs "through predefined code paths"; agents let the LLM direct its own process. Between the two extremes sit the five workflow patterns you build in b3 - prompt chaining, routing, parallelization, orchestrator-workers, evaluator-optimizer - each handing the model a little more of the steering wheel.

  • More autonomy = handles messier tasks, costs more, fails less predictably.
  • Less autonomy = cheaper, testable, boring - and boring is a feature in production.
  • The rule (both vendors): start at the workflow end; slide toward agent only when the task demonstrably demands it.
Demo 1 of 2

Watch one lever change everything ★ 12 min · everyone runs it

The founder asks: "What was March 2026 revenue?" Below is the Daybreak Ops Agent running that task. Step through with Next and read every step - then turn the Tools lever off and step through again. Same model, same question, opposite outcome. This is the failure from the "demo that lied" story, reproduced safely.

Step through with Tools on. Find the moment the model chooses to call query_sales instead of answering directly - that choice is what makes it an agent.

Note the tool result: $150.00, 1 refund excluded. That number is computed live from Daybreak's data, in your browser, right now.

Toggle Tools off. Read the new "answer". It is fluent, specific, confidently formatted - and invented end to end.

Say the lesson out loud: a wrong agent answer usually is not a "bad model" - it is a missing lever. Name the lever first.

How to read every agent demo in this course 👤 user · 🧠 model reasoning · 🔧 tool call · 📦 tool result · 🛡 guardrail · 💬 final answer. The model's words are a scripted teaching simulation replaying the characteristic behaviors; every number in a 📦 step is genuinely computed from the embedded Daybreak data.
Demo 2 of 2

The 12-task scorecard - your course-long benchmark ★ 10 min · explore

Twelve real Daybreak ops tasks, from "what's our refund policy" to "send win-back emails". Start with every lever off and climb: watch WHICH tasks flip to ✓ with each lever, and read the failure text on the ones still red. This exact ladder - 1 → 5 → 7 → 10 → 12 - is the spine of the whole track: each session turns on the lever that unlocks the next rung.

All levers off: 1/12. Only pure arithmetic survives - an LLM alone is a reasoner, not an agent.

+ Tools: 5/12 (b2). Lookups work. But read task 12's failure - tools without guardrails introduced a brand-new danger.

+ Memory: 7/12 (b4). Multi-step comparisons stop losing their own findings.

+ Planning: 10/12 (b5). Diagnoses and reports - tasks that need decomposition - come alive.

+ Guardrails: 12/12 (b7). The two tasks that touch the outside world - sending email, reading untrusted tickets - finally pass safely.

Real world

This scorecard is a real practice, not a toy. Anthropic's agent-evals guidance says to start with 20-50 tasks drawn from real failures and track them continuously; Arize teaches the same decomposition for production agents. In b8 you will formalize this exact golden set - pass@k, trajectory checks, LLM-judges - and in b10 the assembled agent must hit 12/12 before you ship it.

Homework

Try it yourself - this week ◐ 20-30 min total

Source material

Official sources covered

This track teaches the working core of the canonical agent-building sources - Anthropic's and OpenAI's official guidance, the major vendor courses, and the eval literature - with a live agent to poke on every page. Certificates, videos, and graded assessments stay on the official sites (linked each session). This page covers:

✓Anthropic "Building Effective Agents" - definitions + principlesParts 1-2 · workflows vs agents, simplicity, transparency; patterns land in b3
✓OpenAI "A Practical Guide to Building Agents" - pp. 4-13Agent definition + exclusions, when-to-build, model/tools/instructions, exit conditions
✓Hugging Face Agents course - Unit 1 (Fundamentals)Thought-Action-Observation cycle · taught here on live traces
◐DeepLearning.AI "Agentic AI" (Ng) - Module 1Degrees of autonomy + design-patterns overview; patterns built in b3/b5/b6
◐Anthropic Academy "Building with the Claude API" - Agents and Workflows sectionWorkflows-vs-agents lesson; the workflow lessons map to b3
Check yourself

Three questions before you go 🎯 ◐ 90 seconds

1 · What makes a system an agent rather than a workflow?

Anthropic's line: workflows run "predefined code paths"; agents "dynamically direct their own processes." Model size and tool count are irrelevant - who chooses the next step is everything.

2 · The agent quotes revenue that was never in any tool result. Which lever was off?

Hallucinated numbers are the tools-off signature. Planning-off gives shallow half-answers; guardrails-off gives unauthorized actions. Diagnose by lever, then fix.

3 · Why do both Anthropic and OpenAI say to try a workflow BEFORE an agent?

Predefined paths are cheaper, testable, and debuggable. Agents win when tasks are too varied for fixed paths - OpenAI's three criteria. Start simple, escalate deliberately.

Builder session 1 cheat sheet · pin this

Agent in one lineAn LLM in a loop with tools, directing its own next step until the task is done. (Anthropic: "dynamically direct their own processes.")
Not an agentSingle-turn chatbots, classifiers, LLM features on rails - the model never controls what happens next.
The loopGoal → model decides → tool runs → result observed → repeat → answer. Exits: final answer, no tool call, error, max turns.
Inner beatThought → Action → Observation, accumulating in the context window - which IS the agent's working state.
The four leversTools (b2) · Memory (b4) · Planning (b5) · Guardrails (b7). Diagnose failures by lever, not vibes.
The ladder12-task golden set: 1 → 5 → 7 → 10 → 12 as the levers come on. b8 formalizes it; b10 must hit 12/12.
When to agentComplex judgment, unmaintainable rules, or heavy unstructured data - otherwise write deterministic code.
Running projectDaybreak Ops Agent on the MCP-course server: 3 data tools now, action tools + memory + guardrails as the track builds.