Context Engineering
Level 3 · Harder and bigger tasks
Choosing everything a model sees for one request, not just the prompt. Why more text can make answers worse, and how to pick, order and test it.
Course contentsLesson 9 of 16
Level 1 · What a prompt is
Level 2 · Writing a better prompt
Level 3 · Harder and bigger tasks
Level 4 · Prompts inside an app
After this lesson you can
- List what goes into a model's context
- Explain why stuffing the window hurts
- Order the parts of a request for best results
12 mincovers 3 glossary entries
Worth reading first: Prompt Chains and Templates
What a model should see, and what to leave out
Context engineering is choosing all that a model sees for one request. That means the rules, the chat so far, the files and any search results. The context window holds a fixed number of tokens, often 200,000 or more. The job is to fill it with what helps and leave out the rest.
It grew out of prompt engineering. A chat once meant one prompt and one reply. Now an app may add a system prompt, ten old messages, three documents and the results of a search. The words a person types are a small part of what the model reads.
More is not better. Models use the start and the end of a long input better than the middle, so a key fact in the middle is the one most often missed. That is called lost in the middle. A window stuffed full because it fits can bury the part that matters.
Quality also slips as the input grows. A model that follows a rule well in a short prompt can follow it less well at 100,000 tokens. That slow slide is called context rot. It is one more reason to send less, not more.
So choose. Send the three pages that match the question, not the whole 200-page manual. Send the last few messages and a short summary of the rest. Each extra page costs money on every request, and gives the key fact one more place to hide.
Then put it in order. Rules that never change go first, so they are easy to find and can be reused. Long documents go next. The question goes last, close to where the model starts writing. Label each part with tags, so the model knows which text is which.
Test it like a prompt. Run the same questions with more context and with less, and compare the answers. If the shorter one does as well, keep it. It is faster and cheaper, and there is less in it to go wrong.
Worked example
Lucy trims her help bot
Lucy's help bot pasted her whole 120-page manual into every request, about 90,000 tokens. Now it finds the 3 pages that match the question and sends only those.
Each request drops to about 2,000 tokens. On her 40 test questions, the answers get better, not worse, and each request costs a small part of what it did.
The words for this lesson3
Check yourself
Why can sending more text to a model make its answer worse?
Finished this lesson?
Marking it complete also marks its 3 glossary entries learned, which updates your roadmap and your saved page. 0 are already marked.