Chapter 35: The frontier
Models that think first, tools and agents, looking inside, and what nobody knows yet.
You have built a small version of nearly everything in modern AI, and chapter 34 showed you where each piece sits. This chapter is about the right-hand end of that line: the newest parts of the map, which were still being drawn while this book was written, and the edge of it, where the questions have no answers yet.
A warning about dates. This chapter describes things as they stood in late 2026, and this field moves fast enough that some of it will be out of date when you read it. Wherever a number could go stale, it has a date on it.
Thinking before answering
Answer this one fast, without working it out. A bat and a ball cost $1.10 in total. The bat costs $1.00 more than the ball. How much does the ball cost?
5 cents. If the ball cost 10 cents, the bat would cost $1.10 and the two together would cost $1.20. The puzzle comes from the psychologist Shane Frederick. Daniel Kahneman used it in his book Thinking, Fast and Slow, where he reports that more than half of the students who tried it at Harvard, MIT and Princeton said 10 cents. If you did too, you are in good company.
Ten cents is your fast system answering before your slow one gets a turn. Chapter 24 borrowed Kahneman's names for the two: System 1 is the quick gut reaction, and System 2 is the careful working-out.
Now think about the chatbot in chapter 23. Every token it writes comes from one trip through the network, and one trip is a fixed amount of work: the same stack of layers, once. If the first token of the reply has to be the answer, everything has to be worked out inside that single trip. For "what is the capital of France?" one trip is plenty. For a problem with six steps, it is like being made to shout out the bat-and-ball answer the instant you hear the question.
The fix is the one your math teacher keeps asking for: show your work. A reasoning model is a language model trained to write out its working before it answers. Nothing about the machinery is new. It is the same next-token loop. What changes is what the first tokens are for. They are scratch paper.
What is 17 × 24?
17 × 24 is 17 × 20 plus 17 × 4.
17 × 20 = 340.
17 × 4 = 68.
340 + 68 = 408.
Check: 408 ÷ 24 = 17. Good.
17 × 24 = 408.
Why does writing it down help? Because the context window is the only thing carried from one trip to the next. A number the model has written is a number it no longer has to work out again. Each trip does one small step and leaves the result on the page for the trip after it. Written working turns a pile of short trips into one long calculation.
It also lets the model catch itself. A later trip can read an earlier line, find that it doesn't add up, and write a correction. It is part of why newer chatbots usually get the r's in strawberry right (chapter 20): they spell the word out one letter at a time, then count what they wrote.
Researchers noticed in 2022 that showing an ordinary language model a few worked examples, steps and all, made it much better at math word problems. Reasoning models train for it. The model practices on problems whose answers can be checked, such as math and programming puzzles, and it is rewarded when its final answer comes out right. That is the reinforcement learning of chapter 30: nobody marks each line of the working, only the result. It is the "practice at reasoning step by step" that chapter 23 mentioned.
Honesty note: every lab trains its reasoning models a little differently, and most of the details are not published. "Practice on checkable problems, with a reward for the right answer" is the common outline.
A reasoning model writes 2,000 tokens of working and then a 100-token answer. How many trips through the network did that take?
2,100. There is no separate thinking machine. Thinking is tokens, and every token costs one trip. The reader of the answer sees 100 tokens and waits for 2,100.
That is the price. A reasoning model can take many seconds, sometimes minutes, where an ordinary one takes a moment, and it uses more electricity doing it. The companies that sell these models charge for the working as well as the answer, even when the app hides the working. OpenAI tells programmers that one request can use anywhere from a few hundred to tens of thousands of these hidden tokens.
Three limits worth knowing:
- More thinking doesn't add knowledge. A model can reason very carefully from a "fact" it made up. Scratch paper does nothing for the hallucinations in chapter 25.
- The working is not a window into the network. In 2025 researchers at Anthropic slipped hints about the right answer into test questions. The models used the hints, but their written working owned up to it only some of the time: 25% of the time for one model and 39% for another. What a model writes about its reasoning and what its weights actually did are two different things.
- Most questions don't need it. For "is this email spam?", writing an essay first is a waste.
That last point is where the two newest moments on the timeline in chapter 34 meet. The System One models in chapter 24 sit at one end: one trip, one typed answer, nothing written. Reasoning models sit at the other: thousands of trips for one careful answer. They are the fast and slow versions of the same machine, and people who build software now choose between them the way you choose between a glance and a long hard look.
Tools and agents
A reasoning model can work out 17 × 24 on scratch paper. It still can't know what the weather is, what is in your school library, or what happened yesterday. Chapter 23 put it bluntly: everything a model knows is either frozen in its weights or sitting in its context window. Tools are how new things get into the window.
The model does not do it alone. It takes a partner: the app around the model, which is ordinary code with no neural network in it.
- The app describes the tools. Its system prompt lists what is available, what each tool does, and the exact format to ask for it in.
- The model asks. When it decides it needs one, the model writes a request in that format instead of writing an answer. That request is a tool call. It is only tokens, like everything else a model produces.
- The app does the work. It spots the request, runs the search or the calculation or the program, and pastes the result into the context window.
- The model reads on. It runs again, sees the result in the window like any other text, and either answers or asks for another tool.
A model with a calculator tool needs to know 412 ÷ 21. Where does the division actually happen?
In ordinary code. The model writes "please divide 412 by 21" in a format the app understands, and the app does the sum the way any calculator would. In the widget below, you are that app.
You are the app
A student asks a library helper a question it can't answer from its weights. Press the button to do the app's two jobs in turn: send the window to the model, then run whatever tool it asks for. Watch what gets added to the window each time, and who added it.
The model's lines here are scripted by us: no network is running. The school, its library and its books are made up. The calculator is real. When you run it, your browser does the division.
written by the app (you)written by the modelwritten by the student
What just happened
The model ran three times and you ran two tools. The model never opened the catalog and never divided anything. It wrote two short requests and one answer. You never decided anything. You ran what was asked for and pasted in what came back. Neither of you could have answered the question alone.
Every result reached the model the same way: as text in its window, read exactly like the student's question. The model can't open the catalog and check. It takes what the app pastes in.
Now switch the catalog to a copy from 2020 and run it again. The model does everything right and gives a wrong answer, because the library's longest book on the subject was added in 2025 and the old copy doesn't list it. Nothing in the window says the copy is old. Hold on to that.
Loop it and you have an agent
You went around the loop twice: ask for a tool, read the result, decide what to do next. Let the model keep choosing its own next step until the job is done, and you have what people call an AI agent: a language model run in a loop with tools. A coding agent edits a file, runs the program, reads the error message, and tries again. This is where reasoning and tools meet: the model thinks about what to do, does one thing, looks at what happened, and thinks again.
Looking things up before answering
The most common tool of all is a search through documents. Before the model answers, the app looks through a pile of text (a school handbook, a company's manuals, the web) for the passages most related to the question, and pastes them into the window. Fetching text to put in front of the model is called retrieval. Often the search uses embeddings: the app turns the question into a row of numbers and finds the passages whose rows are closest to it. That is the trick behind the word neighbors in chapter 24, applied to whole paragraphs.
This is the "give it a way to look things up" fix for hallucination that chapter 25 promised, and you have just operated it. It helps for a simple reason: copying a fact from a page in the window is much easier than rebuilding it from the weights. And the model can say which page it used, so you can check.
It is not a cure, and you have seen one reason already.
- The source can be wrong or out of date. That was the 2020 catalog. The model passed the mistake along in a confident voice.
- The model can misread the source, or blend what the page says with what its weights half-remember.
- The model can skip the search and answer from memory when it should have looked.
In 2024 researchers at Stanford tested AI research tools sold to lawyers. All were built with retrieval, and their makers had advertised them as avoiding made-up answers. Two of the tools still gave wrong information on more than 17% of the test questions, and a third on more than 34%. That was much better than the general chatbots the same team had tested earlier, which got between 58% and 82% of legal questions wrong. It was also a long way from cured. (Products change quickly. Those numbers describe the tools as they were in 2024.)
More than text
Nothing inside a transformer cares what its tokens stand for. It takes in rows of numbers. In chapter 20 each row belonged to a piece of a word. Turn anything else into rows of numbers and the same network can read that too.
- Pictures. Cut the picture into a grid of small squares called patches. A picture 224 pixels on a side, cut into squares 16 pixels on a side, gives 196 patches. Each patch's pixel values go through one layer of weights and come out as a row of numbers, the same size as a token's row. From there, attention treats the patches like words. The 2020 paper that showed this working is called "An Image is Worth 16x16 Words".
- Sound. Cut the recording into short slices and describe each slice by how much of each pitch is in it. That is the "picture of pitch against time" that chapter 28 mentioned, and each strip of it becomes a row of numbers.
A convolutional network has "nearby pixels belong together" built into its wiring. A transformer looking at patches has to learn that from examples. Given enough examples, it does.
A model that takes in more than one kind of input is called multimodal. OpenAI's GPT-4o, from May 2024, handles text, pictures and sound in a single network. Clef, from chapter 24, reads text and pictures. The image generators in chapter 29 run the same connection in the other direction: text goes in, and a picture comes out.
Small models and your own computer
Chapter 5 said that a trained model is its numbers and nothing else. So a model is a file. If the company that trained it publishes the file, anyone can download it and run it on their own machine. A model shared like that has open weights. Meta's Llama models, Google's Gemma models and Clef all work this way.
Honesty note: open weights does not mean everything is open. You usually get the numbers without the training data, and each model comes with its own rules about what you may use it for.
Will it fit? A weight is normally stored using 16 or 32 bits. Quantization stores every weight more roughly, in 8 bits or even 4, a bit like rounding every price in a shop to the nearest dollar. The file shrinks, and the answers usually get only slightly worse. Take Google's figures for its Gemma 4 models, released in April 2026. The largest has 31 billion weights and needs about 70 gigabytes of memory at 16 bits per weight. At 4 bits it needs about 17.5, which a powerful home computer can manage. The smallest is built for phones and needs about 1 gigabyte.
Small models know less and make more mistakes than the giants. In return, nothing you type leaves your device, the model works with no internet, and you can open it up and study it, which the next section is about.
You can also change a model you have downloaded. That is the fine-tuning from chapter 23: more training, on your own examples. A cheaper version freezes the original weights and trains a small add-on set of numbers beside them. The 2021 paper behind the best-known way of doing this, LoRA, reported that for the 175-billion-weight GPT-3 it cut the count of numbers being trained by a factor of 10,000.
Looking inside
You have been opening networks up all through this book:
- Chapter 17: maps of where each hidden neuron gets excited. Stripes in layer 1, bent shapes in layer 2.
- Chapter 27: one neuron's 784 weights laid out as a picture of the ink it likes.
- Chapter 28: filters nobody designed, which turned out to be edge detectors.
- Chapter 21: the five vowels gathering in one part of the letter map.
- Chapter 22: bars showing which locker the model was looking at.
- Chapter 24: the words the model had filed next to the one you typed.
Each time the move was the same. You didn't settle for the network's score. You opened it and looked at what it had learned. Doing that on purpose, as a science, is called interpretability.
It worked in this book because the networks were tiny. On a big one, two things get in the way. The first is size: the standing-or-ducking network in chapter 25 had 33 weights, and a large language model can have hundreds of billions.
The second is that neurons are mixed up. In chapter 27 you hoped for 64 neat pictures of digits and got smudges, because no single neuron reads a digit. In big networks this gets much stronger. One neuron often takes part in many unrelated things: in one well-studied image network, researchers found a single neuron that responds to cat faces, the fronts of cars, and cat legs. And one idea is spread across many neurons.
Think of an orchestra recorded with a hundred microphones. Every microphone picks up many instruments, and every instrument is heard on many microphones. Listening to one microphone tells you very little. To hear the violin you have to un-mix the recording.
That is what researchers now do. They train a second, helper network whose only job is to describe the big network's activity as a mix of separate patterns, each one a group of neurons that tend to fire together. Many of those patterns turn out to stand for one recognizable thing.
In 2024 researchers at Anthropic used this method on one of their Claude models and pulled out millions of patterns. One responded to the Golden Gate Bridge: to its name in many languages, and to photos of it. Then they reached into the network and turned that one pattern up. The model started bringing the bridge into answers about almost anything, and when asked about its own physical form, it said it was the bridge. So the pattern is not just a label that researchers imagined. It is part of how the model works. A team at OpenAI published similar work on GPT-4 the same year.
In 2025 the Anthropic researchers went a step further and followed patterns step by step through a model while it worked. Two things they found:
- It plans a rhyme. This is the one chapter 23 promised you. Asked for a two-line rhyming poem, the model picked out words that would rhyme (in their example, "rabbit") before it started writing the second line, and then wrote the line to land on that word. When the researchers switched off "rabbit" inside the network, the line ended on "habit" instead.
- It adds in its own way. Asked for 36 + 59, one path through the network worked out roughly how big the answer should be while another worked out the last digit exactly, and the two were combined. Asked afterwards how it got 95, the model described carrying the 1, the way school teaches it. That is not what the tracing showed.
That second finding is the limit from the reasoning section again, seen from the inside: a model's account of its own thinking is one more piece of generated text.
The people doing this work are careful about how far it goes. By their own account, the methods capture only a fraction of what the network is doing, and tracing a prompt a few dozen words long takes hours of human effort. Nobody can yet read a large network the way a programmer reads code.
Why bother? Chapter 25 showed you a classifier that looked for a tag instead of a horse, and researchers only found out by checking what it was looking at. A test score says whether a model got the answers right. Looking inside can say whether it got them right for the right reasons. And these networks were made by training, not by design, so nobody wrote down how they work. Finding out is real science, closer to biology than to engineering.
What nobody knows yet
This book has been full of things that are understood. Here are five that aren't. They are not gaps in this book. Nobody has the answers.
Why do very large networks learn instead of memorize? Chapter 16 left this one hanging. In 2016 researchers took a standard set of labelled photos, shuffled the labels at random, and trained ordinary image networks on the nonsense. The networks fit it easily. So they have plenty of room to memorize a whole training set. Yet given the true labels, the very same networks learn patterns that carry over to photos they have never seen. Why take the pattern when memorizing was on offer? Stranger still, researchers have measured cases where making a network bigger makes its test score worse at first and then better again. One leading idea is that the nudging itself, step by small step, tends to settle on simple solutions. Nobody has a complete theory.
How far does "bigger" keep working? The scaling laws in chapter 18 are measurements, not laws of nature. They say what happened as models grew. They can't promise what happens next, and every step up costs far more than the one before. Some researchers expect more data and more computing to keep paying off for years. Others think new ideas will be needed first. Both groups include serious people, and the only way to find out is to try.
How do you make sure a system does what you meant? You have watched this go wrong three times. The creature in chapter 30 stepped on and off a snack forever because that was what the reward paid for. The headline model in chapter 25 read the agency tag instead of the story. The reasoning models above used a hint and didn't say so. In each case the system did what its training rewarded, which was not quite what anybody wanted. The work of closing that gap is called alignment. It gets more important as agents are trusted with longer jobs and less supervision, and looking inside is one of the tools people hope will help.
What does all this cost in chips and electricity? Chapter 18 added up one training run. Here is the bigger picture. The International Energy Agency reported in 2026 that the world's data centers (all of them, not only the ones running AI) used about 485 terawatt-hours of electricity in 2025. The year before it was 415, around 1.5% of all the electricity used in the world. So the total grew by 17% in one year, and the part used by data centers built mainly for AI grew by 50%. The agency expects about 950 terawatt-hours by 2030, around 3% of the world's electricity.
One question to a chatbot is tiny by comparison. In August 2025 Google estimated that a typical text question to its Gemini chatbot used 0.24 watt-hours, which it compared to watching TV for less than nine seconds. That is the company's own figure, it has not been checked by outsiders, and it covers text only. A reasoning model that writes fifty times as many tokens makes roughly fifty times as many trips. How fast the total will grow, where the power and the chips will come from, and whether models can be made efficient faster than people find new uses for them: nobody knows.
Who gets to decide how these systems are used? The rules are being written right now. The European Union's AI Act became law in August 2024, with its rules arriving in stages over the following years. It sorts uses of AI by how much harm they could do: some are banned, some have strict requirements, some must say plainly that they are AI, and most have no special rules. Other governments are choosing differently. The companies write rules of their own, like the public documents chapter 23 mentioned. Courts are still deciding whether training on people's writing and art without asking is allowed, the question chapter 29 raised. Your school is probably working out its own rules about homework. None of these are engineering questions, and engineers shouldn't be the only ones answering them. You get a say, and a better-informed one than most, because you know how the thing works.
The field is young
Look at the timeline in chapter 34 once more. The paper that made backpropagation famous came out in 1986, which makes it younger than many of your teachers. AlexNet was built by two students and their professor. The transformer is younger than you are, or close to it.
Many of the people on that line began where you are now: curious about how a machine made of arithmetic could possibly learn anything. Every question in the last section is still open, and some of them may well be answered by people who are in middle school today. You already understand the parts they will be working with.
The newest systems are built from parts you already know: the same next-token loop, given scratch paper to think on and tools to reach outside itself. What nobody has yet is a full account of why it works so well, how far it will go, and how to be sure it does what we mean.
Design a tool. Pick a question a chatbot could not answer from its weights, such as "what is for lunch at my school tomorrow?" Write down four things: the tool's name, exactly what the model would send to it, what would come back, and one way the result could be wrong without the model being able to tell.
Then pick the open question from the last section that you would most like to work on. What is the first thing you would measure?
A reasoning model takes thirty seconds over a question that an ordinary model answers in two. What is it doing with the extra time?
The working is made of ordinary tokens, and each one costs a trip through the network. The weights don't change while it answers, and there is no bigger store to search: thinking longer adds steps, not knowledge.
A chatbot with a search tool gives you an answer and a link to the page it used. Why might the answer still be wrong?
The search result is text pasted into the window, and the model reads it like any other text. A wrong page gives a confident wrong answer, as the 2020 catalog did. The link is still worth a lot: it lets you check.
Why can't researchers understand a big network by studying its neurons one at a time?
It is the orchestra and the microphones. The weights are not hidden from the people who trained them, and they stay fixed while you chat. The difficulty is that the meaning is mixed across neurons and has to be un-mixed.