sagelearnai

Agents: Loops, Not Magic

An agent is an LLM running in a loop: it decides what to do next, calls tools, observes the results, and repeats until the task is done. The model supplies the judgment; your code supplies the tools, the loop and the guardrails.

In this lesson

  • Workflows vs agents
  • Common workflow patterns
  • The agent loop (ReAct)
  • A minimal agent from scratch
  • Writing a good agent system prompt
  • Why agents fail
  • Measuring agents

This lesson is part of AI Engineering. Unlock the full course to read it, take the quiz and track your progress.

See plans →

Last reviewed 2026-11-05.