AI agents and MCP

Stage 1 · Lesson 3 of 6

The agent loop

How agents work

Every runs the same loop. Send the conversation and the list of tools to the model. If the reply contains tool calls, run them, append the results to the conversation and call the model again.

If the reply is plain text, the task is finished. This idea comes from a 2022 research paper called , short for reason and act, where the model alternates between thinking, acting with a tool and observing the result. Modern models do the reasoning internally and return structured tool calls, so you no longer parse text, but the rhythm is identical. You will write this loop by hand in the next stage, in about fifteen lines.

Common trapwriting it without a step limit, so one confused run keeps calling tools until your bill, not your code, stops it.

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

  • CoursePaid
    Grokking Modern AI Fundamentals

    Design Gurus · Beginner · $72 one-time

    Chapter 8, Agentic AI, covers reasoning, planning and memory in agents and ends with a small agent project

  • CourseFree
    Hugging Face AI Agents Course

    Hugging Face · Beginner

    Free: Unit 1 explains the thought, action, observation cycle and builds a first agent step by step

Practise

Keep handy

  • The clearest description of workflows versus agents and the common patterns; reread it at every stage

  • A one-page map of agent topics, useful to see where each stage of this roadmap fits

Also worth your time

Mark this stage as not done?