Articles

What Is Context Engineering? Beyond Prompt Design

Context engineering is the discipline of deciding what an LLM sees at inference time — retrieved documents, tool outputs, memory, and history.

Chisato Chisato · · 4 min read
Abstract network of connected nodes representing AI

Context engineering is the practice of deliberately constructing everything an LLM sees at inference time — not just the instructions, but the retrieved documents, tool outputs, conversation history, and memory that get assembled into the model’s context window before it generates a response. Where prompt engineering is about how you phrase a single instruction, context engineering is about the pipeline that decides what surrounds that instruction.

Why this became its own discipline

Early LLM applications were mostly a static prompt plus user input. As applications grew to include retrieval-augmented generation, multi-turn memory, tool results, and multi-agent handoffs, the hard problem stopped being “how do I word this instruction” and became “what information does the model actually need to see, in what order, and what do I leave out.” A model with a poorly assembled context — irrelevant retrieved chunks, stale conversation history, redundant tool outputs — will underperform even with a perfectly worded system prompt, because the context window it has to work with is cluttered or misleading.

Context engineering treats the context window as a scarce, curated resource rather than a bucket you pour everything into.

What goes into the context

A typical production system assembles context from several sources, each with its own engineering problem:

  • System instructions — the model’s role, constraints, and output format. This is the part closest to traditional prompt engineering.
  • Retrieved knowledge — documents or passages pulled from a vector database or full-text search index. The chunking strategy and retrieval quality directly determine whether this content helps or distracts.
  • Tool and function outputs — results from function calls the model made earlier in the same turn, which need to be summarized or truncated rather than dumped in raw.
  • Conversation history — prior turns, which grow unboundedly in long sessions and need active pruning or summarization to stay within budget.
  • Memory — facts about the user or task persisted across sessions, distinct from in-conversation history and usually the most selectively curated layer.

The core trade-off: more context isn’t better context

It’s tempting to solve context problems by adding more — more retrieved documents, more history, more tool output — on the theory that the model can just ignore what’s irrelevant. In practice this backfires in two ways. First, irrelevant or contradictory context measurably degrades output quality; models don’t perfectly filter noise, they get distracted by it. Second, models exhibit uneven attention across long contexts — information in the middle of a very long context window is more likely to be underweighted than information near the start or end, a pattern often called “lost in the middle.” Cramming everything in and hoping the model sorts it out is worse than curating a smaller, more relevant set.

This is also a cost and latency problem, not just a quality one: every token of context is a token the model has to process before it generates anything, and prompt caching only helps when the cached portion is stable across calls — context that changes on every turn (like freshly retrieved documents) can’t benefit from it.

Techniques

  • Selective retrieval — pull only the top-k most relevant chunks, and prefer a reranker pass over raw similarity scores to improve precision before anything reaches the context window.
  • Summarization and compression — replace long tool outputs or old conversation turns with a condensed summary rather than including them verbatim.
  • Structured formatting — presenting retrieved data as clearly delimited sections (headers, XML-style tags, JSON) rather than a wall of prose helps the model attribute information correctly.
  • Just-in-time loading — for agentic systems, fetch context only when a step actually needs it rather than front-loading everything a multi-step task might eventually touch.
  • Context isolation in multi-agent systems — in a multi-agent system, giving each sub-agent only the context relevant to its sub-task, rather than the full shared history, keeps individual agents focused and reduces cross-contamination between unrelated subtasks.

Context engineering vs prompt engineering vs fine-tuning

Prompt engineeringContext engineeringFine-tuning
What it changesInstruction wordingWhat surrounds the instructionModel weights
ScopeA single promptThe full assembled inputThe model itself
Update speedImmediateImmediateRequires retraining
Typical useFormat, tone, task framingRetrieval, memory, tool resultsDomain adaptation, style

These aren’t competing approaches — a production LLM system typically uses all three, and RAG vs fine-tuning is itself a sub-decision within context engineering’s broader question of where knowledge should live.

The takeaway

Context engineering reframes LLM application quality as a data-assembly problem, not just a wording problem. The system prompt is one input among many; what actually determines output quality is what gets retrieved, summarized, remembered, and included alongside it — and, just as importantly, what gets deliberately left out. As agentic and multi-turn systems become the norm, curating the context window well matters at least as much as crafting the instruction inside it.

Chisato Chisato · · 4 min read

What Is Prompt Chaining? Multi-Step LLM Pipelines

Prompt chaining splits a task into a sequence of smaller LLM calls, each one feeding the next, instead of asking one giant prompt to do everything.

#AI #LLMs #Developer Tools
Chisato Chisato · · 5 min read

What Is Catastrophic Forgetting in AI Fine-Tuning?

Catastrophic forgetting is when training a model on new data erases skills it already had. Why it happens during fine-tuning, and how teams work around it.

#AI #LLMs #Machine Learning