Blog › AI agents
What is an AI agent? A plain-English guide
You have probably heard that AI agents will book your flights, sort your inbox and write your code. Underneath the hype, the idea is simple enough to build yourself, and that is exactly what the Questzo AI Agent track does. This guide explains what an agent is, piece by piece.
The short version
An AI agent is a program that uses an AI model to decide what to do next, then does it, then looks at what happened and decides again. A chatbot answers your message. An agent takes a goal and works on it.
Chatbot vs agent
Ask a chatbot "what is 6 times 7?" and it writes back an answer, which may or may not be right. Give an agent the same question and a calculator, and it can notice that this is a maths question, pick the calculator, run it, and give you 42 every time. The difference is not a smarter model. It is the code around the model.
The four parts of an agent
- A model. Something that reads text and writes text back. In Questzo that is Pip, a tiny practice model that runs in your browser and always answers the same way, so your code can be checked fairly. (Chapter 2)
- Tools. Ordinary Python functions the model is allowed to ask for: a calculator, a weather lookup, a dice roller. The model chooses; your code runs the function. (Chapter 3)
- Memory. Notes the agent keeps between steps or between chats, like a list or a file. Without it, every message starts from zero. (Chapter 4)
- A loop. Look, think, act, repeat, with a step limit so it can never run forever, and a check at the end to see if the job is really done. (Chapter 5)
Put several agents together, each with its own job, and you get a team: a boss that splits the work and a crew that does it. That is Chapter 6.
A tiny agent in Python
Here is a complete tool-using agent. You can paste it into Build and press Run.
import pip, json
def calculator(a, b, op):
if op == "+":
return a + b
if op == "*":
return a * b
return a - b
tools = {"calculator": calculator}
reply = json.loads(pip.ask_with_tools("What is 6 times 7?", tools))
if reply["tool"]:
answer = tools[reply["tool"]](**reply["args"])
print("The tool says:", answer)
else:
print(reply["reply"])
Pip reads the question, sees a calculator in the list, and answers with a small piece of JSON: which tool to use and what to give it. Your code does the rest. Real agents work the same way, with a bigger model and more tools.
What agents are bad at
Agents can be confidently wrong, can loop without making progress, and can use a tool in a way you did not expect. That is why good agents have step limits, check their own work, and only get the tools they need. You build each of those safety habits into your bot as you go.
Where to start
If you have never written code, start at Quest 1: it begins with print(). If you already know some Python, skim Chapter 1 and jump to Talk to the Model.
Learn it by building it
Questzo teaches Python by building an AI agent, one pixel quest at a time. The first two chapters are free, with no sign-up.
Start the first quest