Context Engineering: Getting the Right Information to the Model

Prompt engineering asks how to phrase a request. Context engineering asks a bigger question: of everything the model could see, what should actually be in its limited context window right now? It is the skill that most determines whether an LLM system is accurate.

8 min read·By Bryan Rodrigues

What is context engineering?

A language model only knows what is in its context window — the bounded set of tokens it can attend to at once. Context engineering is the discipline of deciding what goes into that window, in what form, and in what order, so the model has exactly what it needs and little it does not.

It is a superset of prompt engineering. Phrasing matters, but in real systems the dominant factors are which documents you retrieve, how you summarise history, which tools you expose, and how you manage a budget that is always smaller than everything you could include.

The context window (finite budget)System instructionsrole, rules, formatRetrieved knowledgeRAG chunks, groundingTool definitionswhat the model can callConversation historycompacted as it growsUser requestthe task right nowModelbounded attentionright tokens,right place
Everything competes for one finite budget: instructions, retrieved knowledge, tools, history, and the user’s actual request.

Why it matters more than prompts

Most production LLM failures trace back to context, not phrasing. The model hallucinates because the grounding it needed was not retrieved. It ignores an instruction because it was buried under thousands of tokens of history. It picks the wrong tool because ten were in scope when two would do.

  • Relevance — include what the task needs and exclude what it does not. More context is not better context.
  • Position — models attend unevenly across a long window; critical instructions and facts belong where they will be seen.
  • Form — structured, compact information is easier for the model to use than raw dumps.
  • Budget — every token spent on noise is a token unavailable for signal, and it costs money and latency.

Core techniques

Retrieval

Pull only the most relevant chunks of your knowledge into context at query time, rather than stuffing everything in. Retrieval quality — chunking, embeddings, ranking — is usually where accuracy is won or lost.

Compaction

As conversations and agent runs grow, summarise older turns into compact state instead of carrying raw history. This keeps the window focused and costs bounded over long tasks.

Structuring

Give the model structure — clear sections, delimiters, and schemas — so it can locate and use information reliably. The same facts in a structured form outperform a wall of prose.

Tool scoping

Expose only the tools relevant to the current step. A smaller, well-described toolset produces far more reliable tool selection than a large one.

Context engineering in practice

In a real system these techniques combine: retrieve grounded knowledge, compact history to stay within budget, structure everything the model sees, and scope tools per step. Done well, the same model produces dramatically more accurate, cheaper, and faster results — without touching its weights.

FAQ

Frequently asked questions

What is context engineering?

+

Context engineering is the discipline of deciding what information goes into a language model’s limited context window — which knowledge to retrieve, how to summarise history, which tools to expose, and how to order it all — so the model has what it needs to answer accurately.

How is context engineering different from prompt engineering?

+

Prompt engineering focuses on how a request is phrased. Context engineering is broader: it manages everything in the context window, including retrieved knowledge, conversation history, and tool definitions. In production systems, context decisions usually matter more than phrasing.

How does context engineering reduce hallucinations?

+

By ensuring the model has the grounding it needs and is not distracted by irrelevant tokens. Good retrieval supplies the right facts; compaction and structuring keep them visible. Most hallucinations are missing-context problems, not model problems.

Building this for real?

AI5 Labs designs, builds, and operates production AI systems. If this is the problem you are solving, let’s talk.

Schedule a discovery session