Skip to content

Context Engineering

Deciding what information goes into a model's context window — instructions, examples, retrieved data and history — to get the best results.

Editorial team 1 min read

Context engineering is the practice of assembling the right information for a model at each step. It extends prompt engineering from wording to the whole contents of the context window.

What Goes Into Context

  • System instructions.
  • Examples.
  • Retrieved documents.
  • Tool definitions and results.
  • Conversation history.
  • Memory and user preferences.

Principles

  • Relevant over exhaustive: more context isn't always better; irrelevant material distracts models and adds cost.
  • Structured: separate sections with clear labels.
  • Fresh: include up-to-date information via retrieval and tools.
  • Prioritised: put the most important information where it will be noticed.

Techniques

  • Retrieval to fetch relevant knowledge on demand.
  • Summarising long histories.
  • Removing old tool output.
  • Loading detailed instructions only when relevant tasks arise.

For Agents

Over many steps, context accumulates. Managing it deliberately is key to long-running agent performance.

Measure

Evaluate changes to context composition just like prompt changes.

More in Generative AI

All Generative AI guides →
Generative AI Guide · 2 min

Prompt Engineering Fundamentals

The building blocks of a good prompt — context, task, constraints and format — with before-and-after examples.

Generative AI 2 min read 24 Jul 2026

Generative AI Guide · 2 min

Few-Shot Prompting With Examples

Showing a model a few examples of the input and output you want is often clearer than describing it. How to choose good examples.

Generative AI 2 min read 23 Jul 2026

Generative AI Guide · 2 min

Getting Structured Output From LLMs

How to get JSON and other machine-readable output reliably from a language model, and how to validate it.

Generative AI 2 min read 22 Jul 2026

Generative AI Guide · 2 min

Why Language Models Hallucinate

What hallucination is, why it happens, and practical ways to reduce and catch it.

Generative AI 2 min read 21 Jul 2026