Module 07 · Context and Grounding
Context Engineering vs Prompt Engineering
A failed AI feature is almost always an architecture failure, not a wording failure.
Overview
Prompt engineering is the craft of writing a static instruction: a role, examples, constraints, and chain-of-thought triggers. It is a real skill, but it hits a ceiling the moment the model lacks information that was never in the prompt. Context engineering is the programmatic assembly of everything the model receives at inference time. One useful picture: a prompt is a script handed to an improv actor, while context is the entire stage, the props, and the briefing dossier assembled before the actor speaks.
The distinction matters because a failed AI feature is almost always an architecture failure, not a wording failure. When a team reports that the model is unreliable, the productive question is not how the prompt is phrased. It is what information the model has and where that information comes from.
This module walks through the four pillars of context engineering. Memory management splits into a short-term rolling window of recent turns and long-term storage of persistent user facts, retrieved semantically when relevant. Retrieval-augmented generation supplies documents the model was never trained on. State management tracks where a multi-step workflow stands, which constraints are satisfied, and what remains pending; without it, agents jump ahead or repeat work. Tool access needs well-defined function schemas plus failure handling for timeouts, errors, and ambiguous results. You will also learn what to keep when context exceeds the window: system instructions, current state, active tool outputs, and retrieved policies rank above conversation history and few-shot examples.
The tradeoffs are token cost, latency, and system complexity, so start with the minimum viable context and expand only when failure modes appear. The common mistakes: endless prompt iteration to fix missing context, retrieval that surfaces irrelevant documents and pays tokens to confuse the model, and skipped state management discovered only when the agent books the same resource twice. Require state diagrams for any multi-step agent before staging.
In one paragraph
Prompt engineering is the craft of writing a static instruction: role, examples, constraints, chain-of-thought triggers. It is useful, but it hits a ceiling the moment the model lacks information that was not in the prompt. Context engineering is the programmatic assembly of everything the model receives at inference time. It handles memory, retrieval, state, and tool access as a coordinated system. A prompt is a script handed to an improv actor. Context is the entire stage, props, and briefing dossier assembled before the actor speaks.
Key ideas
- 01
The four pillars of context engineering are memory management, retrieval-augmented generation, state management across multi-step workflows, and tool access with well-defined function schemas.
- 02
Short-term memory is a rolling window of recent turns. Long-term memory stores persistent user facts and is retrieved semantically when relevant.
- 03
State management tracks where a multi-step workflow is, what constraints have been satisfied, and what is still pending. Without it, agents jump ahead or repeat work.
- 04
Tool calls need failure handling: timeouts, errors, and ambiguous results each require a defined response.
- 05
When context exceeds the window, prioritize system instructions, current state, active tool outputs, and retrieved policies above conversation history and few-shot examples.
- 06
Token cost, latency, and system complexity are the three tradeoffs of context engineering. Start with the minimum viable context and expand only when failure modes appear.
How a senior leader uses this
When a team reports that the model is unreliable, ask what information it has and where that information comes from.
Require state diagrams for any multi-step agent before it reaches staging.
Treat prompt engineering as a junior-level skill and context engineering as a senior-level discipline.
Common failure modes
Endless prompt iteration to fix a problem that is really missing context.
Retrieval systems that surface irrelevant documents, paying tokens to confuse the model.
Skipping state management, then discovering the agent booked the same resource twice.
Further reading
Original source: Context Engineering vs Prompt Engineering on The System Design Newsletter by Neo Kim and collaboratorsShahzad Asghar
Head of Data and Digital Solutions at UN-ESCWA, where he leads AI-driven digital transformation across Arab member states. He writes on AI governance, self-healing pipelines, and data quality at scale. Connect on LinkedIn or visit unaiwork.org.