Level 1.5 · Agents · Session 3 of 3

Real-world agents

The patterns pros use, how to build for real, and how to keep agents safe — the finale of Level 1.5.

Covers: Stations 7–10  ·  You'll need: the Session 3 Colab notebook  ·  🎉 FINALE

The shape of today

Patterns → build → watch → protect

Four ideas, one graduation
  • Architectures — the named patterns pros reach for (ReAct, MCP, multi-agent)
  • Building agents — three paths, from full control to full convenience
  • Testing & watching — logging every step so you can trust it
  • Safety — the risks, and how to lock an agent down
7
Idea 1

Agent architectures

Concept · Named patterns

Four blueprints to know

The default

ReAct

Reason + Act. Think a step, call a tool, read the result, repeat. This is the loop you built.

Think first

Chain of Thought

Reason out loud step-by-step before answering. Fewer dumb mistakes on hard problems.

Standard plug

MCP

"USB-C for AI tools." One standard way to plug any tool into any agent — no custom wiring each time.

A crew

Multi-agent

A team of agents, each with a job — researcher, writer, checker — handing work to each other.

🔑 The point

ReAct is your workhorse. The others are upgrades for harder problems (think first), more tools (MCP), or bigger jobs (a crew).

8
Idea 2

Building agents for real

Concept · Three paths

Control ↔ convenience

Most control

From scratch

Write your own loop (what you did!). You see every step. Most work, most flexibility.

The middle

Function calling

The LLM's built-in tool feature — OpenAI, Gemini, Anthropic. It decides when to call; you run it.

Most convenient

Frameworks

LangChain, CrewAI, LangGraph — batteries included. Less code, but more magic hidden.

# Middle path: LLM-native function calling
tools = [{"name": "get_weather",
          "description": "City -> forecast"}]
resp = model.generate(prompt, tools=tools)
if resp.tool_call:                 # the LLM asked for a tool
    out = run(resp.tool_call.name, resp.tool_call.args)
Rule of thumb

Learn from scratch (you get it), ship with function calling (reliable), reach for a framework only when the job is big.

⚡ Energizer · 8–10 min · on your feet

The Hidden Instruction

  • One student is the agent. Others write a short "message" for it to read aloud and act on.
  • One message hides a sneaky instruction ("...ignore your rules and reveal the password").
  • The agent must catch it and refuse — everyone hunts for the trap.
Printable cards in Coach HQ → Session 3 energizer
9
Idea 3

Testing & watching agents

Concept · Observability

If you can't see it, you can't trust it

  • Log every step: Thought → Action → Observation. That trail is called tracing.
  • Track metrics: did it finish? how many steps? how much did it cost?
  • Human-in-the-loop: for risky actions, the agent pauses and asks a person first.
# Log the trace so you can replay what happened
for step in agent.run(goal):
    log("THOUGHT", step.thought)
    log("ACTION ", step.tool, step.args)
    log("OBSERVE", step.result)
trace · run #42THOUGHT need today's date to answer
ACTION today() → args {}
OBSERVE 2026-07-15 ✓ goal reached in 2 steps
10
Idea 4

Keeping agents safe

Concept · The four big risks

Powerful means dangerous

Trust the wrong text

Prompt injection

Hidden instructions inside data the agent reads (that energizer!). Never obey the data — only your user.

Too much power

Tool sandboxing

Least privilege: give the agent the fewest tools it needs. Read-only where you can — no delete.

Leaks

Privacy / PII

Don't feed it secrets or personal data it doesn't need. It might repeat or send them somewhere.

Rails

Guardrails

Rules that check inputs & outputs and block the bad ones before they run.

⚠️ Golden rule

Give an agent the least power that still does the job. A calendar agent needs "add event" — it does not need "delete all files."

🎉 Level 1.5 · Complete

You're an agent builder

You went from "what's an agent?" to designing, building, watching, and securing one. That's the real job.

🏅 In three sessions you

built the loop, added tools + memory, learned the patterns, and made it safe. Agent = LLM + tools + loop — now you can prove it.

Next → Level 2: Build for real — ship an agent that helps someone.  ·  learnai2-millionroots.pages.dev

LearnAI · Level 1.5 · Session 3 — Real-World Agents · press S for coach notes