Context engineering is the practice of designing everything a model sees when it works on a task: instructions, examples, retrieved documents, conversation history, memory, tool definitions and tool results. Prompt engineering focused on wording a single request. As AI moves into agents that run many steps, reliability depends less on phrasing and more on supplying the right information at the right time, in the right amount, and leaving out what distracts the model.
- ✓Context is everything the model sees, not just the prompt
- ✓Too little context causes guesses; too much causes confusion
- ✓Retrieval, memory and tools are all context
- ✓Agents need context managed across many steps
- ✓Test context changes with evaluations
What is context engineering?
Every time a model responds, it works only from what is in its context window: the system instructions, the user’s message, any documents or examples provided, the conversation so far and the results of any tools it has called. Context engineering is the work of deciding what goes into that window and how it is organised. The term became popular in 2025 as developers building agents found that most failures came from missing, wrong or cluttered context rather than badly worded prompts.
- Wording one request
- Roles, formats and examples
- Mostly manual
- Single turn
- ✓Designing everything the model sees
- ✓Retrieval, memory, tools and history
- ✓Built into systems
- ✓Many steps and sessions
What makes up a model’s context?
Our guides to RAG, AI agent memory and MCP cover three of these in depth.
Why has the focus shifted?
Models have become much better at understanding plain instructions, so clever phrasing matters less. At the same time, AI is being asked to do longer tasks: researching across many sources, writing code across a codebase, handling a support case end to end. These tasks fail when the model lacks a key fact, is given outdated information or is overwhelmed by irrelevant detail. Larger context windows help, but quality still drops when important information is buried among noise.
How do you engineer good context?
-
1
Start with the taskDefine what a good result looks like and what information it needs.
-
2
Write clear instructionsPlain language, priorities and rules for uncertain cases.
-
3
Retrieve selectivelyFetch only the most relevant, current documents for each step.
-
4
Structure the contextUse headings or tags so the model can tell instructions from data.
-
5
Manage historySummarise or trim long conversations and agent steps.
-
6
Describe tools wellClear names, descriptions and examples for each tool.
-
7
Evaluate changesTest every context change against a set of real cases.
Why does context matter more for agents?
An agent might take dozens of steps, calling tools and reading results each time. Without management, its context fills with old tool outputs and side details, and it loses track of the goal. Good agent design summarises progress, keeps a short list of key facts, drops irrelevant results and sometimes splits work across sub-agents with their own focused context. Our posts on multi-agent systems and why AI agent projects fail show the patterns.
How does context affect cost and speed?
Every token in the context is processed on every call, so bloated context makes AI slower and more expensive as well as less accurate. Trimming history, retrieving fewer but better documents and caching stable instructions can cut costs noticeably. Our guide to reducing LLM API costs covers caching and model routing in more detail.
How does context affect security?
Anything placed in context can influence the model, including hidden instructions in web pages or documents. Context engineering therefore includes deciding what untrusted content is allowed in and how it is labelled. See our guide to AI security and prompt injection.
Does this make prompt engineering obsolete?
No. Clear instructions and good examples are still part of context. But the skill has widened from writing prompts to designing information flows: what to retrieve, what to remember, how to describe tools and how to measure results. For non-technical users, the practical lesson is to give AI the background a new colleague would need: the goal, the audience, relevant documents, examples of good work and what to avoid. Reusable packages such as Claude Skills and project knowledge bases make this easier.
- Share the goal and the audience
- Attach the documents that matter, not everything
- Show one or two examples of good output
- State constraints and what to avoid
- Ask the model to say when information is missing
What does this look like in practice?
A support team’s AI assistant gives vague answers about refunds. The prompt is fine; the context is the problem. It retrieves an old refund policy alongside the new one and has no access to the customer’s order. The team removes outdated documents from the knowledge base, retrieves the order record for each case, adds two example replies and summarises long ticket histories. Accuracy on their test set of 150 real tickets improves, and escalations fall.
How UIUX Studio helps
We design and build AI assistants and agents with well-engineered context, retrieval and evaluation. Talk to our Agentic AI & Automation team.
