BeginnerCoder

Lesson 1 — What an agent is

A model that can act

A large language model (LLM) is a program trained on huge amounts of text: you give it text, it writes a reply. ChatGPT, Claude and Gemini are LLMs. On its own an LLM can only talk.

An agent is ordinary Python code wrapped around an LLM so it can do things. It runs a loop:

  1. Think — ask the model what to do next.
  2. Act — your code performs the action the model chose (look something up, do maths, read a file).
  3. Observe — your code hands the result back to the model. Then it thinks again, until it has a final answer.

How this course works: a real agent sends its messages over the internet to a model API (a web address programs talk to) from a provider such as OpenAI, Anthropic or Google Gemini, using a secret API key. These lessons run inside your browser with no internet and no keys, so we use fake_llm — a small Python function that pretends to be the model with simple if-rules, so every run gives the same output. In a real agent you replace fake_llm with the API call. The loop, the tools and everything else you write stay the same.

Why it matters: think → act → observe is the skeleton of every agent you will build in this course.

Want it another way?
Task

The program thought, acted and observed once. Finish the loop: think again — call fake_llm with the same goal and notes, and print the decision with "think:" in front.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.