Skip to content

Interview question · Context Engineering & Caching

What is context engineering, and why does an agent need it when the model already has a 200k-token window?

The question that separates people who have run long agents from people who have read the window size. The strong answer treats the window as a budget spent every turn, shows the arithmetic, names rot, and lists the levers a harness has over what the model sees.

easyNewUpdated Nov 2026

TL;DR: Context is everything in the request: instructions, tool definitions, the transcript, tool results and anything retrieved. The harness rebuilds it on every turn, so a run of thirty steps reads the growing transcript thirty times, and the bill rises with the square of the step count. Quality falls long before the window is full: long transcripts full of stale tool results make the model miss instructions and repeat work. Context engineering is deciding what goes in, in what order, what is trimmed or summarised, and what is kept stable for caching. A bigger window raises the ceiling and changes none of that.

How to approach it

Define context as the request, not as "memory". Then give the two reasons the window size is not the constraint: cost per turn and quality per token. Do the arithmetic for one run. Then list the levers, in the order you would pull them. Interviewers ask this to hear whether you think of the context as something the harness assembles or something that just accumulates.

A strong answer

The model is stateless. Each turn, the harness sends it the whole picture again: the system instructions, every tool definition, every message so far, every tool result, and whatever was retrieved for this turn. That request is the context. Nothing the model saw last turn survives unless the harness sends it again (The Context Window as a Budget).

That makes the window a budget spent per turn, not a container filled once:

illustrative run
  steps                                 30
  stable prefix (instructions + tools)  6,000 tokens
  transcript growth per step            ~2,000 tokens (call + result)
  input tokens on step n                6,000 + 2,000 n
  total input over the run              sum over n = 1..30
                                        = 30 * 6,000 + 2,000 * 465
                                        = 1,110,000 tokens

Thirty steps that each fit easily in a 200k window still read over a million tokens. One tool result of 8,000 tokens left in place at step 3 is re-read 27 more times. The cost of context is paid on every later turn, which is why the harness cares what stays in.

The second reason is quality. Models attend unevenly over long inputs: instructions at the top compete with pages of tool output, details in the middle get missed, and a transcript full of stale results invites the model to act on old state or repeat a call it already made. This degradation, context rot, starts well below the window limit and shows up as an agent that worked for ten steps and drifts after twenty (Context Rot). A larger window lets you fail later; it does not fix the attention problem.

So context engineering is the harness's set of decisions about the request:

LeverWhat it decidesTypical move
SelectionWhat enters at allOnly the tools this task can use; retrieve for this turn, not everything
ShapingWhat a tool result looks likeTruncate, summarise, return a page, keep the full payload fetchable
OrderWhere things sitStable instructions and tools first, volatile material last
ReductionWhat leaves over timeClear old results, compact the transcript into notes at a threshold
CachingWhat stays byte-identicalA fixed prefix, so the provider reuses it instead of re-reading it

The order matters for a reason beyond attention: providers cache a stable prefix, and one changed byte near the top invalidates everything after it. Putting a timestamp in the system prompt is the classic way to pay full price every turn.

Authority line: the model works with what it is shown; the harness decides what it is shown. When an agent "forgets" an instruction on step 25, the first question is what the request looked like on step 25, not what the model is capable of.

What interviewers probe next

"We just moved to a model with a million-token window. Problem solved?" The ceiling moved. Cost per turn still grows with the transcript, rot still sets in before the limit, and a run that fills a million tokens costs a million tokens per step near the end. The levers are the same.

"What do you drop first when a run gets long?" Old tool results, replaced by a one-line note of what they said, because they are the bulk and the model acted on them already. Instructions and the task statement go last; they are small and they steer everything.

"How do you know rot is happening rather than a bad model?" Compare the same task at step 5 and step 25 in traces: repeated calls, ignored instructions, stale state. Then re-run with the transcript compacted; if the behaviour returns, the context was the cause.

How it's scored

Weak: Equates context with the window size, or describes context engineering as "better prompts".

Hire: Defines context as the per-turn request, explains cost growth and rot, and names selection, shaping, ordering, reduction and caching as the harness's levers.

Strong Hire: Also does the per-run arithmetic, explains why order affects cache hits, says what to drop first and why, and describes how to tell rot from model limits using traces.

Common mistakes

  • Thinking the model remembers earlier turns on its own.
  • Leaving large tool results in the transcript for the rest of the run.
  • Putting volatile text at the top of the prompt and losing the cache every turn.
  • Treating a bigger window as the fix for drift.
  • Compacting away the task statement or the instructions along with the clutter.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 6, and the site remembers where you stopped in each one.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in raises your free answers from 5 to 6 per topic, adds an applied lesson in every topic and easy practice tests, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

Nobody has commented. Post a correction or another way to answer.