Skip to main content

Context Engineering

Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/context-engineering

In short

Context engineering is the practice of choosing what an LLM sees on each call (instructions, documents, tool results, history) so it can do the task reliably.

What is context engineering?

A language model only knows what is in its context window at the moment it answers: the system prompt, the conversation so far, and whatever else the application puts in. Context engineering is the work of deciding what goes into that window, in what form and in what order, on every single call.

Prompt engineering is about phrasing a good instruction; context engineering is about everything around it. For an AI agent that means retrieving the right documents, summarizing long histories, passing in tool definitions and their results, keeping notes it can return to, and leaving out what would only distract it. The term spread in 2025 as agents began running long, many-step tasks.

The window is limited and every token costs money and attention, so more context is not always better. Models tend to miss details buried in very long inputs, and stale or contradictory information leads them astray. Good context engineering keeps what the model needs for this step, close to where it will use it, and drops the rest.

Key takeaways

  • Context engineering decides what an LLM sees on each call: instructions, data, tool results and history.
  • It is broader than prompt engineering, which focuses on the instruction itself.
  • Retrieval, summarization and memory are its main tools in AI agents.
  • More context is not better context: irrelevant or stale text makes answers worse.

Example

Building the context for one step of an agenttypescript
// Fit the most useful pieces into a fixed token budget, most important first
function buildContext(task: string, history: Message[], docs: Doc[], budget: number): Message[] {
  const context: Message[] = [{ role: "system", content: INSTRUCTIONS }];
  let used = countTokens(INSTRUCTIONS) + countTokens(task);

  for (const doc of docs.slice(0, 3)) {
    // the three best-matching documents, if they fit
    if (used + countTokens(doc.text) > budget) break;
    context.push({ role: "user", content: `Source: ${doc.text}` });
    used += countTokens(doc.text);
  }

  // older turns are replaced by a short summary
  context.push({ role: "user", content: `Earlier: ${summarize(history)}` });
  context.push({ role: "user", content: task });
  return context;
}

Readers ask

Is context engineering the same as prompt engineering?

No, it is wider. Prompt engineering is about how you word the instruction; context engineering is about all the information the model receives with it, including retrieved documents, tool results, memory and conversation history.

Why not just put everything into a model with a huge context window?

Because cost and quality both suffer. Long inputs are slower and more expensive, and models tend to overlook details buried in the middle of them, so a short, relevant context usually gives better answers than a long, complete one.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings