Building with AI

What is context engineering?

In short

Context engineering is the work of deciding exactly what information an AI model gets before it answers: instructions, documents, conversation history and tools.

A language model only knows what is in its training and what is in front of it right now, its context. Context engineering designs that second part on purpose: which instructions, which facts, how much history and which tools to include, and what to leave out. It goes beyond writing a good prompt, because most of the context is assembled by the system, not typed by a person.

Mini course

3 short lessons, about 2 minutes in total

  1. The model only sees what you give it
  2. What goes into the context
  3. Getting it right

Lesson 1

The model only sees what you give it

A language model starts every task knowing only its training. Everything specific to your company, the customer, the case and the rules has to be placed in its context: the text it reads before answering. If a fact is missing there, the model guesses.

Context window
Context engineering decides what the model sees before it answers: instructions, the right documents, the conversation so far and the tools it may use

Tap a box to open that concept

Context engineering is the discipline of putting the right things there, every time.

Lesson 2

What goes into the context

A typical context has a few parts: standing instructions on role and rules, relevant documents found by search, the conversation so far, results from tools such as a database lookup, and the task itself. Each part competes for room in the context window.

Good systems choose each part for the task at hand instead of including everything.

Lesson 3

Getting it right

Start with the task and ask what a skilled person would need on their desk to do it. Include that, in a clear order, and leave the rest out. Summarize long histories. Label documents with titles and dates. Test with real cases and look at what the model actually saw when it got something wrong: the cause is usually there.

  1. Customers find youHow customers and AI tools find the companySEOGEOGoogle AI Overviews
  2. AI in daily workTools staff and customers useChatbotAI copilotVoice AI
  3. Building blocksHow AI connects to data and systemsContext engineeringRAG (retrieval-augmented generation)AI agentMCP (Model Context Protocol)
  4. AI modelsThe models that understand and createLarge language model (LLM)Generative AIMachine learning
  5. DataCompany data, gathered and cleanedData warehouseETLData quality
  6. InfrastructureCloud, networks and systems underneathCloud computingDatabaseAPI key
Trust and rulesSecurity, law and control in every layerGDPR and AIEU AI ActAI guardrails
Where Context engineering sits in a company's AI setup

An everyday example

A customer service assistant gets the company's tone rules, the customer's last three orders, the return policy and nothing else, so it answers a return question correctly instead of guessing.

How companies use it

Companies use context engineering when they build assistants and agents: choosing what each step sees, keeping long conversations short and on topic, and connecting the right data sources.

Frequently asked questions

How is context engineering different from prompt engineering?

Prompt engineering is about wording one instruction well. Context engineering is about everything the model sees, most of which is assembled automatically: documents, history, tool results and rules.

Is more context always better?

No. Too much or irrelevant text makes answers slower, more expensive and often worse. The aim is the smallest set of information that lets the model do the task well.

Does context engineering need programming?

For a chat assistant, much can be done with instructions and attached files. For agents and integrations, it is mostly built into the software around the model.

In depth: Context engineering

The full picture, about 3 minutes of reading

Why context decides quality

A language model does not know your business. It knows a huge amount about the world in general, frozen at the time it was trained, and nothing about your customers, prices, routines or today's case. Everything it needs for a specific task has to be in front of it when it answers. That material is called the context, and its upper limit is the context window.

When an AI assistant gives a weak or wrong answer, the cause is very often not the model but the context: the right fact was missing, buried under irrelevant text or contradicted by an outdated document. Context engineering is the practice of designing that input on purpose, so the model has what it needs and little else.

From prompts to context

Early advice on using AI focused on prompt engineering: how to phrase a request. That still matters, but in real systems the person's request is a small part of what the model reads. An assistant or agent also gets standing instructions, retrieved documents, earlier messages, results from tools and sometimes memory from earlier sessions.

Most of that is assembled by software, not typed by a person. Context engineering is about designing that assembly: which pieces are included, in what order, how they are labeled and when they are summarized or dropped.

The main building blocks

Instructions set the role, the goal, the rules and the format of the answer. They should be short, specific and free of contradictions. Knowledge comes from search over your own documents, as in RAG, and should arrive with titles, dates and sources. History is the conversation so far, which grows quickly and often needs to be summarized. Tools are the actions the model may take, such as looking up an order, and their results become part of the context too. Memory is what the system keeps between sessions, such as a customer's preferences.

Each block takes room, and room is limited. Even with very large context windows, models tend to pay less attention to material in the middle of a long context, so less is often more.

Common mistakes

The most common mistake is including everything just in case: whole manuals, long histories and every tool. This raises cost, slows answers and gives the model more chances to grab the wrong fact. The second is stale or conflicting material, such as two versions of a policy. The third is missing labels, so the model cannot tell an old email from a current rule. The fourth is never looking at what the model actually saw when it failed.

In agents that work over many steps, a fifth problem appears: the context fills with tool output until the original goal is lost. Good agents regularly summarize progress and keep the goal in view.

How to work with it

Start from the task and ask what a capable new employee would need on the desk to do it well. Write that down as a list: rules, facts, examples and tools. Build the system to supply exactly that, labeled and in a sensible order. Then test with real cases, and for every wrong answer, inspect the full context the model received. Fix the context before you consider changing the model.

Over time, keep sources current and assign someone to own them. Context engineering is never finished, because the business changes.

What it means for a small business

For a small business, context engineering shows up in practical choices. When setting up a chat assistant, it means writing clear instructions and attaching only the documents that matter. When building an assistant on company documents, it means cleaning up old versions and giving files clear names. When automating a process with an agent, it means deciding what each step should see.

These choices usually matter more for the result than which model is used, and they are within reach without a large budget.

Sources: Liu et al., Lost in the Middle (2023)

Curious what this could mean for your company? Book a call.

Book a call