The word "agent" sounds mysterious. In fact there is a loop behind it. Let's take it apart on a real example.
Translated from Russian. Original
Imagine you write to ChatGPT:
"Here is a task: find where to buy cheap bread.
Here are the tools: google, open a site, read the content.
If you want to call a tool, answer: "call tool X with parameters Y""
What happens next:
1. ChatGPT answers: "call "google search" with query "cheap bread""
2. You google it yourself and bring the list of links back to it
3. It says: "read site 1" - you bring the content; then "read site 2", and so on for each link
4. Now it has 10 pages with prices in context - and it just picks where it is cheaper
Did you notice the mechanics? The model only thinks and says which tool to pull. You do all the work by hand: google, open, bring the result back - and ask again "what next?"
This is the agent. Only a program runs the loop instead of you.
An agent is an endless loop of three things: {LLM + context + tools}.
How it runs:
1. The program asks the LLM: "what to do next?"
2. The LLM answers: call this tool
3. The program calls the tool, gets the result
4. The result goes back into the context
5. Back to step 1
And round and round - until the task is solved.
That's all. No magic. An agent is not a finished product and not a being with a will. It is a control program that runs the LLM in a loop and feeds it tools and the context it has built up. The LLM thinks, the program executes, the result comes back - and the loop repeats.
In Claude Code this agent loop is built in: it works exactly like this inside. But to really understand the mechanics, it is useful to write your own - from scratch, in one day. When you close this loop with your own hands, "agent" stops being a trendy word and becomes a clear engineering construction.
We will go through such an implementation step by step in the next posts.
#agents101