Learning HubContext and GroundingContext Engineering 101

Module 06 · Context and Grounding

Context Engineering 101

The hardest problem in production AI is not phrasing the question. It is deciding what information the model should see at each step.

Overview

Context engineering is the discipline of managing the information a model sees at the moment it generates a response. Context is more than the prompt. It includes the system prompt, the conversation history, examples, tool outputs, retrieved documents, and any other data the model can read. The hardest problem in production AI is not phrasing the question. It is deciding what information the model should see at each step.

The constraint is physical: the context window is finite, and dumping more information into it often makes answers worse. Models bias attention toward the start and end of the window, so material in the middle can be ignored. Long-running tasks suffer from context rot, the pattern where useful information gets buried under outdated tool outputs and stale conversation turns. Good context engineering curates the minimum useful information at each step.

The module teaches the working techniques. Retrieval strategies fall into three patterns: load everything upfront for clear questions, retrieve just in time for exploratory tasks, or combine both, which is what most production systems do. Compaction summarizes the conversation, keeps the essentials, and discards the rest when the context approaches its limit. Structured note-taking runs continuously: the agent writes goals, constraints, and decisions to a separate file that can be reloaded later. Sub-agent architectures give focused subtasks their own context windows and return condensed summaries to the main agent. Progressive disclosure starts with summaries and drills into full sources only when they look relevant, which mirrors how skilled researchers work.

The failures are recognizable. Teams stuff entire documents into the prompt and hope the model finds what matters. They run multi-hour agents without external notes and lose state when the context fills. They let one agent handle everything when sub-agents would keep each context clean. Review context management plans with the same seriousness as database schemas, and require a compression policy before approving long-running deployments.

In one paragraph

Context engineering is the discipline of managing the information a model has at the moment it generates a response. Context includes the system prompt, conversation history, examples, tool outputs, retrieved documents, and any data the model can see. The context window is finite. Dumping more information into it often makes answers worse because models bias attention toward the start and end of the window. Good context engineering curates and composes the minimum useful information at each step, compresses what is stale, preserves what is durable in external notes, and splits work across sub-agents when a single context gets overwhelmed.

Key ideas

  • 01

    Context rot is the pattern where useful information gets buried under outdated tool outputs and conversation turns. It degrades long-running tasks.

  • 02

    Retrieval strategies fall into three patterns: load upfront, retrieve just in time, or a hybrid. Upfront loading fits clear questions. Just-in-time retrieval fits exploratory tasks. Most production systems combine both.

  • 03

    Compaction summarizes the conversation so far, keeps essentials, and discards the rest. Use it when the context approaches its limit.

  • 04

    Structured note-taking runs continuously. The agent writes goals, constraints, and decisions to a separate file that can be reloaded later.

  • 05

    Sub-agent architectures assign focused subtasks to separate agents with their own context windows, then return condensed summaries to the main agent.

  • 06

    Progressive disclosure means starting with summaries and drilling into full sources only when they look relevant. This mirrors how skilled researchers work.

How a senior leader uses this

  • Review context management plans with the same seriousness as database schemas.

  • Ask where durable decisions live when a conversation ends.

  • Require a compression policy before approving long-running agent deployments.

Common failure modes

  • Stuffing entire documents into the prompt and hoping the model finds what matters.

  • Running multi-hour agents without any external notes, then losing state when the context fills up.

  • Letting one agent handle everything when splitting work across sub-agents would keep each context clean.

Further reading

Original source: Context Engineering 101 on The System Design Newsletter by Neo Kim and collaborators

Shahzad 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.