
The Journey to AI Part 4 - How AI Agents were born
How next-word prediction became ChatGPT and how ChatGPT became something that can act in the world.
In this article
- The Journey to AI Part 4
- From Text Predictor to AI Agent: The Last Leap
- Why “Predict the Next Word” Is Secretly Genius
- Scale: The Bet That Paid Off
- Emergence: Abilities That Appear From Nowhere
- The Raw LLM Is Just Autocomplete
- RLHF: Teaching It to Be an Assistant
- But Even ChatGPT Is Still Caged
- The Agent: Opening the Cage
- Ingredient 1: Tools
- Ingredient 2: The Loop (ReAct)
- Ingredient 3: Memory
- You’re Looking at One Right Now
- The Whole Journey, in One Breath
- Where It Goes From Here
The Journey to AI Part 4
From Text Predictor to AI Agent: The Last Leap
How next-word prediction became ChatGPT and how ChatGPT became something that can act in the world.
Part 4 of 4 in “The Journey to AI Agents”
Here’s the training task that powers ChatGPT, Claude, and every modern AI you’ve heard of:
Predict the next word.
That’s the whole thing. A machine reads text, guesses what comes next, gets corrected, adjusts its billions of knobs, repeats. Across hundreds of billions of words from the internet.
And somehow, from that absurdly simple task, something resembling understanding emerges.
Let’s trace the last steps: from autocomplete to assistant, and from assistant to agent.

Why “Predict the Next Word” Is Secretly Genius
This training task sounds trivial. It isn’t. Two reasons.
Reason 1: The data labels itself.
For next-word prediction, the correct answer is just the word that actually came next in the original text. Which means all raw text on the internet is automatically labeled training data, no humans required.
Wikipedia articles. Every GitHub repository. Books, scientific papers, Reddit threads, news, code, forums. Hundreds of billions of words, all self-labeled, ready to train on.
Reason 2: To predict well, it must actually understand.
Consider what the model has to figure out to consistently predict well:
"The murderer, revealed in the final chapter, turned out to be the ___"
→ must track a complete plot arc"2 + 2 = ___"
→ must do arithmetic"The French word for 'cat' is ___"
→ must know translation"def add(a, b): return ___"
→ must understand code logicGrammar. Facts. Math. Translation. Coding. Reasoning. None of this was explicitly taught. It emerged because it’s necessary to predict text well across all of human writing.
The technical term for this is compression forcing comprehension, to predict the next word accurately across billions of diverse examples, the model has no choice but to learn the underlying structure of how humans think.
Scale: The Bet That Paid Off
The training task wasn’t new. What changed was scale. Take the same Transformer architecture from Part 3 and make it enormous:
GPT-1 (2018): 117 million parameters
GPT-2 (2019): 1.5 billion parameters ← "too dangerous to release"
GPT-3 (2020): 175 billion parameters ← the jaw-dropperMore parameters. More data. More compute. Same loop.
The key discovery: scaling laws. Performance improved smoothly and predictably as you added parameters, data, and compute. You could forecast that a 10× bigger model would be approximately X% better before spending the money to build it.
Spending $10 million on a training run went from a gamble to a calculated bet. And once that was true, the race to scale was inevitable.

Emergence: Abilities That Appear From Nowhere
Here’s the part that still surprises researchers.
Some abilities don’t improve gradually with scale. They’re absent in smaller models, near-zero accuracy. Then, past a certain size threshold, they appear. Not gradually. Suddenly.
These are called emergent abilities, and the most striking one is in-context learning.
Show GPT-3 a few examples in the prompt, and it figures out the pattern without any weight update, without any retraining:
Prompt:
sea otter → nutria de mar
cheese → queso
car → ___
Model: cocheNobody programmed “learn from prompt examples.” Nobody fine-tuned it to do this. It emerged from scale. The same happened with multi-step reasoning, code writing, and logical deduction, all without being explicitly trained on them.
It was genuinely surprising. Even to the people who built it.
The Raw LLM Is Just Autocomplete
Here’s the catch. A freshly pretrained LLM has no interest in helping you.
You: "What is the capital of France?"
Raw LLM: "What is the capital of Germany? What is the capital of Spain?"On the internet, questions are often followed by more questions. The model is doing its job perfectly, predicting the most plausible continuation of the text. It just has no instinct to answer questions, follow instructions, or be useful.
It’s a brilliant brain in a jar. Extraordinary knowledge. Zero social contract.

RLHF: Teaching It to Be an Assistant
Two steps turned the raw model into something the world actually wanted to use.
Step 1: Supervised Fine-Tuning.
Thousands of human-written (instruction → ideal response) pairs teach the model the format of a helpful assistant that answers rather than rambles.
Step 2: RLHF - Reinforcement Learning from Human Feedback.
a) Model generates several answers to a prompt
b) Humans rank them: best to worst
c) Train a "reward model" that learns to predict human preferences
d) Use that reward model to fine-tune the LLM further
→ maximize the reward → helpful, honest, safe responsesApply this to GPT-3, package it as a chat interface, release in November 2022: ChatGPT.
100 million users in two months.
The fastest product adoption in history. AI went mainstream overnight. Not because the underlying model suddenly became smarter, but because it learned how to talk to people.

But Even ChatGPT Is Still Caged
Even aligned, the LLM has hard walls:
- It can’t look things up - its knowledge is frozen at the training cutoff
- It can’t run code - it can only describe code, not execute it
- It can’t remember you across conversations
- It can’t take actions - send emails, search the web, write files
Text in. Text out. No more.
All that intelligence, all those capabilities, all that knowledge from the entire internet, and it can’t do anything that requires stepping outside the text box.
A brain in a jar. But the jar is about to shatter.
The Agent: Opening the Cage
Here’s the insight that changes everything:
An LLM is extraordinarily good at one thing: reading a situation described in text and reasoning about what to do next.
So:
What if the LLM’s text output could trigger real actions, and the results of those actions were fed back as new text in a loop?
That’s an agent. Three ingredients:
Ingredient 1: Tools
A tool is any function the model can request: web search, code execution, reading a file, querying a database, sending an email, calling an API.
Crucial subtlety:
The LLM cannot actually run anything. It only outputs text requesting an action. A surrounding program the harness, sees that request, executes it, and feeds the result back as text.
LLM outputs: ACTION: search("next Summer Olympics host city")
│
(the harness, not the LLM, runs the actual search)
│
Harness feeds: OBSERVATION: "Los Angeles, 2028."The LLM stays a pure text predictor. The intelligence is in the model. The agency is in the harness.
Ingredient 2: The Loop (ReAct)
THOUGHT → reason about what to do next
ACTION → call a tool
OBSERVATION → receive the result
(repeat until goal is reached)Watch it handle a question no single LLM call could answer:
“What’s the current weather in the city hosting the next Summer Olympics?”
THOUGHT: I need to find the next Summer Olympics host city.
ACTION: search("next Summer Olympics host city")
OBSERVATION: "Los Angeles, 2028."
THOUGHT: Now I need the current weather in Los Angeles.
ACTION: get_weather("Los Angeles")
OBSERVATION: "24°C, sunny."
THOUGHT: I have all the information I need.
FINAL ANSWER: The next Summer Olympics is in Los Angeles. Current weather: 24°C and sunny.The LLM never searched or checked the weather. It only reasoned and requested. The harness did the real work. But by chaining steps, it solved something that would have been impossible in a single pass.

Ingredient 3: Memory
Short-term: the context window, the running transcript of thoughts, actions, and observations in the current task.
Long-term: a vector database the agent can write to and search later, persisting information beyond any single conversation. Ask about something you mentioned three sessions ago, and the agent retrieves it. This is RAG (Retrieval-Augmented Generation).
For large goals, agents also plan: break a big objective into a checklist of sub-tasks, then execute them one by one through the loop.
You’re Looking at One Right Now
Claude Code is exactly this architecture.
An LLM, running in a ReAct loop, with tools: read a file, run a terminal command, edit code, search the web. That’s why it can actually create and edit files instead of just describing them. That’s why it can run tests and fix the failures.
The brain in a jar got hands, a loop, and memory.
The Whole Journey, in One Breath
Start from 1950. Every line is one obstacle found and dropped:
"Can a machine think?" → test BEHAVIOR, not philosophy
Symbolic AI (rules) → brittle, unscalable, can't perceive
↓ drop: humans writing rules
Learning from data → guess→check→adjust on examples
Perceptron → one line, can't solve XOR
↓ drop: single neurons
Backpropagation → trains the hidden layers
Deep Learning → depth + data + GPUs cracks perception
↓ drop: hand-engineered features
Word embeddings → meaning as geometry
RNNs / LSTMs → handle sequences, but bottlenecked + slow
↓ drop: sequential processing
Attention / Transformer → every word sees every word, in parallel
↓ scale it massively
LLM → next-token prediction + RLHF = assistant
↓ drop: text-only output
Agent → tools + loop + memory = acts in the worldEvery breakthrough was someone staring at the current limitation and asking: “What’s the one assumption causing this?” Then dropping it.
Where It Goes From Here
Even now, agents have hard limits that are actively being worked on:
- Compounding errors - one bad reasoning step in a long loop can derail everything that follows
- Hallucination - LLMs still state false things with total confidence
- Long-horizon planning - staying coherent across hundreds of steps is unsolved
- Multi-agent systems - multiple specialized agents collaborating is just beginning
But from “can a machine think?” in 1950 to an agent that can browse the web, write and run code, and execute multi-step real-world tasks in 2026, in 76 years, is genuinely remarkable.
And it all started with one mathematician refusing to answer an unanswerable question.
This was Part 4 of “The Journey to AI Agents.” Start from Part 1 to trace the full path from the 1950s to today.
Tags: AI Agents, Large Language Models, ChatGPT, RLHF, ReAct, Machine Learning, Artificial Intelligence
Originally published on Medium on June 28, 2026.
Comments
Coming soon.