Lessons and outlineLesson 6 of 11
AI Concepts in PicturesLesson 6
Context Engineering: What Goes on the Desk
Choose what the model sees, keep it tidy, and keep long jobs on track.
Context engineering is choosing what goes on the model's desk: rules, tools, facts, memory, history and the question. Keep it tidy and short. For long jobs, summarize history, keep notes and fetch on demand.
- Context
- Everything the model can see when it answers.
- Memory
- Short notes the app saves and adds to later chats.
- Summarize
- Replace long old text with a short note of what matters.
Prompt engineering asks how to word one request. Context engineering asks a bigger question: what should be on the desk when the model answers? The desk is the context window. In a real product, many things compete for that space. Choosing well is now one of the most useful skills in AI. This lesson shows how.
What goes on the desk
- Rules: who the model is and what it must never do.
- Tools: the list of tools it may use, with descriptions.
- Facts: documents found by search.
- Memory: notes saved from earlier chats.
- History: the messages so far in this chat.
- The question: what the user just asked.
All of these use tokens. The desk has a limit. If you stuff everything on, the model can get lost, and you pay for every piece.
Switch items on and off. Change the window size.
Too full by 6,050 tokens. Something must be cut, often the oldest history. Remove an item, summarize history, or use a bigger window.
Principles of a tidy desk
- Only what helps: every item should earn its place. Remove the rest.
- Fresh and true: old or wrong facts mislead the model.
- Right order: stable things first, changing things last. This also helps caching.
- Short and clear: a crisp page beats a long, vague one.
- Findable: if the model must hunt, put important text at the start or the end, not buried in the middle.
Keeping long jobs on track
In a long task, the history grows. Three habits help.
- Summarize old history. Replace twenty old messages with a short note of what matters.
- Write notes outside the chat. Save decisions in a file, and bring them back when needed.
- Fetch on demand. Do not load every document up front. Let the model search when it needs one.
Memory in plain words
Models do not remember by themselves. Memory is a feature built around them. The app saves short notes, such as the user prefers metric units. It adds the notes to the desk in later chats. Good memory saves only what is useful, lets the user see and delete notes, and avoids private data.
[Rules] You are a travel helper. Never book anything without asking. [Tools] search_flights, search_hotels [Memory] Prefers window seats. Travels with one child. [Facts] (found now) Airline baggage rules, 2 pages [History] (last 6 messages, older ones summarized) [Question] Find me a flight to Chennai on Friday.
A before and after
A team's bot kept forgetting the user's name and repeating itself. They looked at the desk. The history was a long, messy block. The rules were buried in the middle. They moved the rules to the top, summarized old messages and saved the name as a memory note. The bot became steady, and each chat cost less.
Revisit the desk whenever the product changes. A new tool or a new document adds weight. Remove old items as often as you add new ones.
Keep a changelog of what you add to the desk. If answers get worse, you can see what changed.
- ✓Context engineering is choosing what goes on the model's desk.
- ✓The desk holds rules, tools, facts, memory, history and the question.
- ✓Keep it tidy: only what helps, fresh, well ordered and short.
- ✓For long jobs, summarize history, keep notes and fetch on demand.
- ✓Memory is a feature the app builds, and it needs user control.
Audit a desk
- Pick a chatbot or assistant you use.
- Guess what is on its desk: rules, tools, facts, memory, history.
- Mark anything that might be missing or that might be wasting space.
- Write two changes that would make its answers better.
Q1How is context engineering different from prompt writing?show answer
Prompt writing words one request. Context engineering chooses everything on the desk, including facts, memory and tools.
Q2Why summarize old history?show answer
It saves tokens and keeps the model focused on what matters.
Q3Why keep secrets off the desk?show answer
The model can read them, and they can leak into answers.