Hello, Robot Brain! What Is Context Engineering?
Hello, Robot Brain! What Is Context Engineering?
Maya tore a strip of packing tape with her teeth, pressed the last cardboard flap into place, and sat back on her heels to admire what she had built. It was not a beautiful robot. It was a tall cereal box with a juice-carton head, two paper-cup ears, and a single wobbly antenna made from a pipe cleaner. But on the front of the box, in careful purple marker, she had written a single word: HELLO.
Maya was eight. She had spent the entire Saturday afternoon turning trash into a machine, and now she wanted the machine to talk back. So she did what any reasonable eight-year-old would do: she opened the flaps at the back, dropped in a small notebook filled with handwritten answers, and began to ask questions.
"What is your name?" she said.
She flipped the notebook to the first page, which read: *My name is Crumbo. I am a robot who lives in this box. I like buttons and stars.*
"My name is Crumbo," said the box.
Maya grinned. "What do you like?"
She flipped to the second page. "I like buttons and stars."
"Do you know what day it is?"
She flipped to the third page. It was blank. The box said nothing. Maya waited. The box said nothing. Finally, in a small voice, Maya answered her own question.
"It's Saturday," she whispered.
Then she thought of something clever. She ran to the kitchen, fetched a sticky note, and wrote on it: *Today is Saturday, October 12. Maya is talking to me. Her favorite color is blue.* She pressed the sticky note to the inside of the notebook cover, so it would be the very first page Crumbo "saw."
Now, when she asked, "Do you know what day it is?" the box answered: "Today is Saturday, October 12."
She clapped. "Do you know who I am?"
"My name is Maya," said the box, "and your favorite color is blue."
Maya rolled onto her back on the carpet and laughed at the ceiling. She had invented a robot. It was the greatest afternoon of her life.
Then, a few minutes later, she asked, "What is my favorite color?"
Silence.
Maya frowned. She lifted the sticky note. It was still there. "But I just told you," she said to the box. "I told you about Maya. I told you about Saturday. Why don't you remember?"
The box said nothing, because the box had never said anything at all. The notebook was just paper. But Maya had stumbled onto the exact puzzle that every grown-up who builds real robots — the kind made of code and electricity and math — has to solve: a model only knows what you put in front of it, and what you put in front of it is everything.
That is what this book is about. We are going to spend fourteen chapters learning how to put the right things in front of an AI model at the right moment, in the right shape, in the right order, so that it can do useful work for us. The grown-up name for this is context engineering, and it is one of the most important skills in the entire field of artificial intelligence. By the end of this chapter, you will understand what context is, why careless context makes models stupid, and how to build a tiny chatbot that becomes dramatically smarter the moment you take context seriously. You will also meet Maya again, because Maya's cardboard robot is the perfect first teacher.
Let's begin with the question that started Maya's adventure: what does an AI model actually know?
What a Model Knows (and What It Doesn't)
An AI model — let's call it a "thinking engine," the way you might call a car an "engine on wheels" — is a very large piece of software that has been trained. Training is the process of showing the engine billions of examples of text so that it learns patterns. After training, the engine has stored inside it a huge bundle of *parameters*: numbers, billions and billions of them, that encode everything it has learned. Those numbers are the model's weights. They live inside the model like memories live inside your brain — except that no one, not even the people who built the model, can read them directly. The weights are the model's *training*.
But here's the trick. Once training is finished, the weights stop changing. If you trained the model last year, the model does not automatically know what year it is now. It does not know what you said two minutes ago. It does not know the name of your dog, your favorite ice cream flavor, or the fact that today is your birthday. It knows what was true when it was trained, in general, averaged across billions of web pages. It does not know anything that has happened since, and it does not know anything about *you*, specifically.
What the model needs, in order to be useful, is context: the complete set of information that you, the user or the developer, hand to the model at the moment it generates a response. Context is *runtime information*. It is the sticky note Maya pressed into her notebook. It is the cheat sheet. It is the briefing. It is the script the actor reads before walking onto the stage. The model itself is the actor; the context is the script.
To make this concrete, imagine you hire a brilliant actor who has memorized every play ever written. The actor knows Shakespeare, Chekhov, every joke in every sitcom, the entire script of every movie. But if you walk up to that actor on a random Tuesday and say, "Tell me about my dog," the actor will stare at you blankly, because your dog was never in any play. The actor is missing runtime information. Now imagine you hand the actor a single index card that says: *The user has a dog named Biscuit, a golden retriever, who likes to sleep on the left shoe.* Suddenly the actor can answer any question about Biscuit — because the actor has the context.
That index card is context. The actor is the model. The plays are the weights.
This is the first big idea of the book, and I want you to remember it so clearly that you could explain it to a friend on the playground. A model's training is its permanent memory. A model's context is its working memory. Permanent memory is huge but frozen. Working memory is small but fresh. Clever AI builders spend most of their effort managing the working memory, because that is where the action is.
A Concrete Inventory of What "Context" Usually Contains
When you give a model a piece of text to respond to, the text isn't usually a single sentence. It's a context window, which is the entire chunk of text the model is allowed to look at while it thinks. A context window is like a small desk. Only the things on the desk are visible. Everything else is in a closet somewhere, and the model cannot reach it.
Inside the desk, you typically find four kinds of things:
1. The system prompt. A short, hidden set of instructions written by the developer that tells the model how to behave. Things like: "You are a friendly tutor for nine-year-olds. Never use words longer than three syllables. Always end your answer with a question." The user usually doesn't see the system prompt, but the model always sees it. 2. The conversation history. Every message the user has sent so far, and every response the model has given. This is how the model "remembers" what you said earlier — except, as we will see, the memory is shallow and easily lost. 3. Retrieved information. Extra facts the system pulls in from outside, like snippets from a manual, a list of products, or a passage from a book. This is how a model knows about things it wasn't trained on. 4. The user's current message. Whatever the user just typed.
Some builders also include things like tool definitions, examples of good answers, instructions in multiple languages, or rules about what *not* to do. We will meet all of these later in the book. For now, just remember: context is the whole desk, not just the question.
A Picture of the Pipeline
Here is the flow, end to end, of what happens when you type something into a chatbot. Read it from top to bottom, left to right. The arrows are the path your words travel.
```merm