Context engineering
Why it matters
A model's output cannot be better than what it is given. Hand a coding agent an entire codebase and it drowns. Hand it the two files that matter plus a short note on conventions and it does the job cleanly. Many answers that look like model failures are context failures: the right fact was missing, an old rule contradicted a new one, or a hundred irrelevant pages buried the one that counted.
How to apply it
- Give the model only what the task needs. Fewer, better inputs beat more.
- Write stable conventions down once, in a rules file or system prompt, and supply them every time.
- Keep a short record of decisions already taken, so the model does not reopen them.
- Retrieve reference material on demand instead of pasting everything in. Retrieval-Augmented Generation (RAG) does this.
- When output drifts, inspect what the model was given before blaming the model.
What it is
An AI model only knows what sits in front of it when it answers. That material is its context: the instructions, the documents, the earlier conversation and the tools it can call. Context engineering is the work of choosing and arranging all of it so the model has what it needs and nothing that distracts it.
Prompt engineering is the narrower skill of wording one instruction well. Context engineering covers the whole package around that instruction, and it matters most when AI agents run many steps with no person watching.
Common mistakes
- Treating a longer prompt as a better one.
- Leaving outdated or contradictory rules in the supply.
- Never checking what the model actually received.
The four parts
- Instructions: what the model is asked to do and how.
- Knowledge: the documents and records relevant to this task only.
- Memory: decisions already made, so settled questions stay settled.
- Tools: what it may look up or change, described clearly.