Learn · 01
How AI agents work
From a model that guesses the next word to an agent that finds you jobs every morning. Eight stops, no code. Each stop has something to press.
- 01The brain
- 02Tokens
- 03Context window
- 04What is an AI agent
- 05Memory
- 06Tools
- 07Autonomy
- 08Workflow or agent
Stop 01 · The brain
An LLM guesses the next word
ChatGPT, Claude and Gemini are all large language models (LLMs). Each one has read a huge amount of text and learnt one skill: given some words, guess what comes next. Do that very fast, over and over, and you get whole answers.
A good CV should be
Illustration. The words and percentages are made up to show the idea. A real model scores tens of thousands of options at every step.
Remember. On its own, an LLM only writes text. It cannot open a file, search the web or send an email. And it sounds just as sure of itself when it is wrong.
Stop 02 · The units
It reads in tokens, not words
The model cuts text into small pieces called tokens. A token can be a whole word, part of a word, or a space plus a word. Everything is counted in tokens: what you pay, and how much the model can read at once.
A real split, not a guess. The dot (·) marks a space that belongs to the token. A box marked ×2 holds two tokens that only make sense together. Try English, then Hindi: same meaning, roughly twice the tokens.
Remember. Rough rule for English: one token is about four characters, or three quarters of a word. Hindi and many other languages need more tokens for the same meaning, so they cost more.
Stop 03 · Working space
The context window is its desk
The model can only see what is on its desk right now: your messages, its replies, any files you gave it. The desk has a fixed size. When it is full, the oldest pages fall off, and the model simply cannot see them any more.
Remember. A bigger desk remembers more of the chat. But everything on the desk is sent again with every message, so a bigger desk also means more tokens and more cost.
Stop 04 · Putting it together
What is an AI agent?
An LLM on its own can only talk. An AI agent is an LLM that can get things done: you give it a goal, and it works step by step, using tools and memory, until the job is finished.
You ask Find me 3 React jobs in Bangalore posted this week.
It replies
“I can't search job sites or see this week's listings. I only know what was in my training. Here are some tips: keep your profile updated, search for ‘React developer’ on job boards, and set up alerts.”
Helpful words, but the job is not done. It cannot look anything up or act.
An agent is four parts
Remember. Agent = LLM + memory + tools + autonomy. The LLM is the brain you have already met. The next three stops take the other parts one at a time.
Stop 05 · Remembering
Two kinds of memory
Short-term memory is the desk: this conversation only. Long-term memory is a filing cabinet: notes saved somewhere permanent, like a sheet or a database, that the agent can look up later, even in a brand new chat.
Short-term · the desk
Long-term · the filing cabinet
1/4 Monday. You chat with the agent and it finds you three jobs. All of this sits on the desk.
Company names are made up.
Remember. The model itself does not remember you. Memory is always something we build around it: what we put on the desk, and what we save and fetch later.
Stop 06 · The hands
Tools are its hands
A tool is an ability you hand the model: search jobs, read a file, save a row, send a message. You describe each tool in plain words. The model reads those descriptions and decides on its own which tool to use, and when.
Goal Find me up to 3 new jobs that fit my résumé.
The tools it was given
- Press play to watch it work.
Illustration of a typical run. Steps 0/6.
Remember. Nobody wrote “if there are too few jobs, search again”. The model decided that from what came back. That loop (decide, use a tool, look at the result, repeat) is what makes it an agent.
Stop 07 · Who decides
Autonomy: who picks the next step?
Not every AI system should make its own decisions. Slide through the levels, using the same job search each time.
- What it is
- You give it a goal and some tools. It chooses the steps.
- Our job search, at this level
- Finds jobs that fit you, searches again if results are weak, skips ones you have seen.
- Who decides the next step
- The model, while it runs.
- How predictable
- Less predictable. Steps and cost change from run to run.
Remember. More autonomy means it can handle more, and you can predict less. Use the lowest level that does the job, and keep a human check before anything that cannot be undone.
Stop 08 · The test
Workflow or agent?
One question decides it: can you draw the flowchart before it runs? If yes, it is a workflow, and you should build it as one, because it is cheaper, faster and easier to fix. Use an agent only where the next step depends on what it finds.
Workflow · steps fixed in advance
Agent · steps chosen while running
| Workflow | Agent | |
|---|---|---|
| Who picks the next step | You, when you build it | The model, while it runs |
| Number of steps | Known in advance | Depends on what it finds |
| Cost | The same every run | Changes from run to run |
| When it breaks | You see which step failed | You read its trail of steps |
| Good for | Sort, summarise, send, move data | Search, research, judge, fix |
Illustration. Results are made up to show the difference.
Remember. Good systems mix the two: a workflow on the outside, and an agent only for the step that needs judgement.
Sources
- Token splits on stop 02: gpt-tokenizer, using o200k_base, the tokeniser OpenAI uses for GPT-5 mini.
- Everything marked “illustration” is made up to show an idea, not measured.