Promptwatch Logo

Context Engineering

Context engineering is the practice of choosing what goes into an LLM's context window (instructions, retrieved content, tools, memory) to get reliable outputs.
Updated October 15, 2026
AI

Definition

Context engineering is the practice of deciding what information goes into a language model's context window at each step, and in what form, so the model produces the intended result. The context includes the system instructions, the user's request, retrieved documents, tool definitions and tool results, conversation history and any stored memory. Context engineering treats all of it as something to select, order, compress and refresh, rather than focusing only on the wording of one prompt.

The term spread in mid-2025 as developers moved from single prompts to agents that run for many steps. Anthropic's engineering team described it in September 2025 as 'the natural progression of prompt engineering', and defined the goal as finding 'the smallest possible set of high-signal tokens that maximize the likelihood of some desired outcome' (Effective context engineering for AI agents). Prompt engineering is one part of it; context engineering also covers what the system retrieves, which tools it exposes, and what it forgets.

The reason it matters is that more context is not automatically better. Chroma's Context Rot study (July 2025) tested 18 models and found that performance became less reliable as input length grew, even on simple tasks. Anthropic calls this an 'attention budget': every token added draws on it. Windows have grown to about 1 million tokens for current Claude, GPT-6 and Gemini models, but filling them with loosely related material still lowers accuracy and raises cost.

Common techniques include:

  • Retrieval and reranking to put only the most relevant passages in front of the model (retrieval-augmented generation).
  • Just-in-time loading, where an agent keeps references such as file paths or URLs and fetches content with tools only when needed.
  • Compaction: summarizing a long conversation or agent trace and continuing in a fresh window with the summary, and clearing old tool results.
  • Structured note-taking, where an agent writes notes to memory outside the window and reads them back later.
  • Sub-agents that explore a task in their own clean context and return a short summary to the main agent.
  • Clear formatting and tool descriptions, so the model can tell instructions, data and tools apart.

For AI search, context engineering happens on the engine's side. When ChatGPT, Perplexity or Google AI Mode answer a question, they run searches (see query fan-out), fetch pages, and then select which passages to put into the model's context before it writes the answer. Only content that survives that selection can be cited. A page that answers the question in a compact, self-contained passage near the top is easier to select than one where the answer is spread across a long introduction, tabs or images.

That gives content teams a practical checklist: lead each section with a direct answer, keep facts such as prices, dates and specifications in plain text, make passages understandable on their own without the rest of the page (content chunking), and avoid hiding key information behind client-side rendering. The same habits help any retrieval system, including the internal assistants your customers build on top of your documentation.

Examples of Context Engineering

  • A support agent retrieves the three most relevant help articles, reranks them, and passes only the top passages plus a short conversation summary to the model, instead of the full help center.
  • A coding agent keeps file paths in context and opens files with tools only when a step needs them, so a large repository never fills the context window.
  • A long-running research agent compacts its history every few hours into a summary of findings and open questions, then continues in a fresh context.
  • A documentation team rewrites each page section to start with a one-sentence answer and moves version numbers out of images into text, after noticing AI assistants quoting outdated details.

Terms related to Context Engineering

Context Window

A context window is the maximum number of tokens an LLM can consider at once, covering input and output. Frontier models offered about 1 million tokens in 2026.

AI

Prompt Engineering

Prompt engineering is writing and testing instructions for language models so they produce consistent, useful output. It now sits within context engineering.

AI

Retrieval-Augmented Generation (RAG)

Retrieval-augmented generation is a technique that pairs a language model with a retriever, so each answer is written from documents fetched for that query.

AI

Reranking

Reranking is the second retrieval stage, where a precise model rescores candidate passages so only the most relevant few reach the LLM that writes the answer.

AI

Content Chunking

Content chunking is splitting text into smaller segments: a step retrieval systems run before indexing, and a writing practice of self-contained sections.

GEO

AI Agents

AI agents are AI systems that pursue a goal over many steps: they plan, use tools such as search, a browser or code, act on results and ask humans when needed.

AI

Query Fan-Out

Query fan-out is how AI search splits one question into several sub-queries, runs them at once and merges the results, so pages compete on each sub-query.

AI

AI Grounding

AI grounding ties a model's answer to verifiable sources, such as live search results or supplied documents, so each claim can be traced and cited.

AI

Tokens

Tokens are the units of text a language model reads and writes, such as word pieces or punctuation. They set context window limits, API prices and rate limits.

AI

Frequently Asked Questions about Context Engineering

Learn about AI visibility monitoring and how Promptwatch helps your brand succeed in AI search.

Prompt engineering focuses on writing and structuring instructions, especially system prompts. Context engineering manages everything the model sees at each step: instructions, retrieved documents, tool definitions and results, history and memory. It is iterative, because an agent's context changes after every action. Prompt engineering is one component of the broader practice.

Be the brand AI recommends

Monitor your brand's visibility across ChatGPT, Claude, Perplexity, and Gemini. Get actionable insights and create content that gets cited by AI search engines.

Promptwatch Dashboard