Build a Real AI Agent · Part 1

Your AI Can’t Check the Weather (Yet): What Is an AI Agent?

Ayman Hamed· 9 November 2026· 3 min read
Part 1 of 4Build a Real AI Agent
  1. Your AI Can’t Check the Weather (Yet): What Is an AI Agent?
  2. Five Lines to Talk to a Model (and Why It Forgets You)
  3. Why AI Types Word by Word
  4. The Model Has No Hands
AI AgentsLLMBeginners

Open any AI chat and ask it:

"What's the weather in Cairo right now?"

One of two things happens. It apologises — "I don't have access to real-time data" — or, worse, it confidently invents a number. Twenty-eight degrees and sunny. Sounds right. Might be completely wrong.

That moment is the best place to start learning about AI agents. Because the model in that chat is very smart, and it still cannot do the simplest thing a five-year-old with a window can do: look outside.

The brain in a jar

A large language model (LLM) is a brain in a jar. Text goes in, text comes out. That's the whole deal.

It cannot:

  • open a web page,
  • read a file on your laptop,
  • run a line of code,
  • remember you tomorrow.

It only talks. Everything else you've seen AI "do" — book a meeting, fix a bug, search the web — was done by code around the model, not by the model.

That code is what we call an agent.

So what is an agent?

Here's the definition we'll use for this whole series:

An agent is an LLM in a loop: it decides, acts with tools, looks at the result, and decides again.

Let's see it with the weather question.

  1. You ask: "What's the weather in Cairo?"
  2. The model decides: "I can't know that. But I see there's a tool called get_weather. I'll ask for it — with city = "Cairo"."
  3. Your code acts: it runs the real get_weather("Cairo") function and gets "30°C, Clear".
  4. The model looks at the result and decides again: "Now I know. I'll answer."
  5. You get: "It's clear and 30°C in Cairo right now."

The agent loop: you ask, the model decides, your code acts, the model observes, and it repeats until it can answer.

The model never touched the internet. It asked, your code did, and the answer went back into the conversation. Decide → act → observe → decide again. That little circle is the heart of every agent you've ever heard of — coding assistants, research bots, customer-support agents. Same circle.

Chatbot vs agent, side by side

A chatbot…An agent…
only talksuses tools to act
forgets you when the tab closesremembers you across sessions
gives one answer and stopsloops until the job is done
has no idea when to give upknows when to stop

Every line in the right column is something you will build, in plain Python, in this series.

Why build it yourself?

There are frameworks that hand you an agent in three lines. They're great — after you understand what they hide. Until then, they feel like magic, and magic is impossible to debug.

Here's the surprising part: the core of an agent is tiny. The loop that makes it work is about fifteen lines of code. Once you've written those fifteen lines yourself, every framework, every "agentic" product, every conference talk suddenly makes sense. You'll look at them and think: oh — it's the loop.

If you can't build it from scratch, you don't understand it.

What's next

In the next article we take the very first step: talking to a model from Python in about five lines — and discovering something strange: the model forgets everything between two messages.

Try this before then: ask your favourite AI chat what time it is right now, then check your clock. Notice how it answers. That's the gap we're about to close.

Continue: Five Lines to Talk to a Model (and Why It Forgets You)
ShareXLinkedInWhatsApp

Comments

Loading comments…