What an agent is, in code: a model, a list of tools and a loop that decides when to stop. Built from the Hugging Face and Microsoft beginner courses.
Out on Monday 12 October10 minutes, one build start to finish
Why this matters
Most agent tutorials start with a framework and hide the part that matters. Under every agent is a model, a list of tools and a loop that decides when to stop. Seeing that loop once in plain Python makes every framework easier to understand and every agent bug easier to find.
What you build
An agent that calls your own tools in a loop, in about a hundred lines of Python.
Install smolagents and connect it to a model.
Write two tools as plain Python functions with the tool decorator.
Run the loop: the model picks a tool, reads the result and decides whether it is done.
Read the steps it took, and see how a vague tool description sends it the wrong way.
The ideas behind it
The agent loop
The model reads the task, picks a tool, reads the result and decides whether it is done. That repeats until it stops.
Tools as functions
A tool is a Python function with a clear name and description. The model chooses it from the description alone.
Why descriptions matter
A vague description sends the model to the wrong tool. Better descriptions fix more agents than better models.
Before you start
You need
Python 3.10 or later, and an API key for a model provider or a free Hugging Face token.
Length
About 10 minutes, one build start to finish.
Questions
Which model do I need?
Any model with tool calling. A free Hugging Face token is enough to follow along.
Why smolagents?
It is small enough to read, so the loop stays visible. The same ideas apply to every agent framework.
What should I build next?
Give the agent a real tool from your work, then trace a run to see each decision it makes.
Is the recorded lab free?
Yes. Watch it any time, follow the steps and keep the code you build.
How is it different from a Live Lab?
A recorded lab is one short build you follow on your own. A Live Lab builds a bigger part of the system in an hour, with time for your questions.