GlossaryContext engineering
Context engineering
Context engineering is the practice of deciding what information a language model receives at each step of a task: the instructions, retrieved documents, tool definitions and results, memory and conversation history that fill its context window. It extends prompt engineering from writing one prompt to managing everything the model sees.
How it works
A model knows only what is in its context window plus what it learned in training. For an agent working through many steps, that window fills with instructions, tool definitions, tool outputs, documents and earlier turns. Context engineering decides what goes in, in what form and in what order, and what is left out or summarized.
A 2025 survey of the field groups the work into retrieving and generating context, processing it and managing it, with techniques such as retrieval, compression, structured memory and tool integration. Protocols such as the Model Context Protocol give agents a standard way to discover tools and pull in resources, which makes those choices part of the system's design.
More context is not always better. A 2023 study found that models used information at the start and end of a long context better than information in the middle. Irrelevant or stale context also distracts models, and every token costs time and money.
Context engineering vs prompt engineering
Prompt engineering focuses on writing the instructions and examples in a prompt. Context engineering covers the whole input across a task: which documents to retrieve, which tools to expose, what to remember between steps and what to drop. Prompt engineering is one part of it.
Why it matters
Most agent failures trace to context, not to the model: a missing datasheet, an outdated revision, too many similar tools or a long history that buries the current goal. Getting the context right improves accuracy, cuts cost and makes behavior more predictable.
How to get it right
- Retrieve only the documents the current step needs, at the right revision.
- Expose a small set of clearly described tools for each task.
- Summarize long histories, keeping decisions and open questions.
- Put key instructions and facts at the start or end of the context.
- Keep long-term notes in an external store and load them when relevant.
- Log the exact context for each step so failures can be traced.
Context engineering in robotics and drone hardware
Hardware tasks pull in heavy context: schematics, BOMs, datasheets, design rules and test logs. Loading the right revision of each, and only the sections the step needs, is what lets an agent check a footprint or a rule without drowning in pages. Engineers building tools around their hardware data spend much of their effort here.