When an agent gets something wrong, the first instinct is to blame the model and the second is to swap it. Open what the model actually received on that call and the diagnosis usually changes. The fact it needed was never in its input, or left at a compaction an hour earlier, or sat under tens of thousands of tokens of definitions for tools the session never used. The model answered the input it was given. The input was assembled badly, and nobody owned the assembling. Context engineering is the name for owning it.

Thesis: Context engineering is the discipline of deciding, on every call, what the model sees, what lives outside the window, and how it is brought in when the call needs it; many agent failures that look like model failures are context failures, and the way to tell them apart is to read what the call carried.

TLDRThree steps, about thirty seconds
its inputsystem prompttool definitionshistorytool resultsits inputoutsidetool schemasencryption policyencryption policy40 of 61 rowsre-bought on every callBoth versionsa progress fileits inputthe tools this job usesencryption policyrow idsits inputsystem prompttool definitionshistorytool resultsits inputoutsidetool schemasencryption policyencryption policy40 of 61 rowsre-bought on every callBoth versionsa progress fileits inputthe tools this job usesencryption policyrow ids

Step 1 of 3

What Context Engineering Means

The usual reflex when an agent fails: blame the model, then swap it.

Read what the call actually carried, and the diagnosis usually changes: the input was badly assembled.

Read the TLDR as text
  1. What Context Engineering Means. The usual reflex when an agent fails: blame the model, then swap it. Read what the call actually carried, and the diagnosis usually changes: the input was badly assembled.
  2. An Enterprise Illustration. By default the harness keeps everything, resends everything and writes nothing down. Here: unused connector schemas paid for every call, two policy versions, and a row count with no ids.
  3. What to Do Next. No model fault here, and a bigger model would get the same input. Assembled on purpose: only the tools the job uses, one policy version, and row ids written to a progress file.

The Model Sees Only What the Call Carries

An agent conversation feels continuous. The model's side of it is not. If you came through The Agentic Lifecycle, it ended on that fact: what survives from one call to the next is only what your code keeps. This series is about deciding what that is, the Context layer of the harness in Model, Harness, Agent. The model is stateless: everything it knows on a call is in that call's input, and the whole conversation is in its input every time, whether your code resends it or the provider stores it. Anatomy of a Turn measures how much of each call is resent.

Why a new name, when prompt engineering already exists? A prompt is one piece of text a person writes. An agent's input is assembled by code on every call, from a system prompt, tool definitions, a growing history, tool results and retrieved passages, over a task that can run to hundreds of calls (One Request, End to End shows call 100 of a 224-call session). Most of what call 100 carries, nobody wrote for call 100. Anthropic's engineering post on context engineering (2025-09-29) calls it "the natural progression of prompt engineering", and sets it against "the discrete task of writing a prompt" as work that is iterative. The skill is deciding what the input holds each time it is rebuilt.

Three words carry the series, used the same way across Start here, this site's reading path for newcomers:

  • A request is what the user asks for: one task, which may take many calls to finish.
  • A call is one model API call: one input in, one response out.
  • A turn is one call plus the tool runs it triggers.

Context engineering works at the level of the call, because the call's input is the thing that gets assembled. You have met most of the other words already, and each is in the glossary: token, context window, system prompt, tool and its definition, harness, subagent (an agent another agent starts, with its own fresh window), retrieval, compaction (the harness replacing the transcript with a summary when the window nears its limit) and skill. One is new here: a connector is an integration that gives the agent tools for one outside system, such as a ticketing system or a document store.

Two things follow. "What did the model know when it answered" has an exact answer per call: what was in that call's input, and nothing else. And every call is a fresh chance to assemble the input well or badly, because the model re-reads all of it.

Three ideas hold the series together, all three this site's own: the three decisions below, four kinds of context sorted by who may write them, and five ways context fails. Every later chapter applies them, and any other list you meet is a working tool, not a fourth idea. By the end you should be able to read any call your agent makes, say what each part is and where it came from, pick the technique that fixes what is wrong, and keep decisions and shared state correct across sessions and agents.

This site's definition is operational. On each call, three decisions are being made, whether or not anyone makes them on purpose:

  1. What is in the window on this call. The always-on set (identity, hard limits, the tools this job uses) and the per-call set (the task, its current state, the facts this step acts on).
  2. What lives outside the window. Files, a progress log, a ticket system, a knowledge service, the records themselves, each with its own lifecycle and owner.
  3. How the outside is brought in. Resent by the harness, returned by a tool, selected by code before the call, or written down by one step and re-read by the next.
flowchart LR
    subgraph Out["2. Outside the window"]
        F["Files and progress log"]
        T["Tickets and records"]
        K["Knowledge service"]
    end
    B["3. Brought in<br/>resent, returned by a tool,<br/>selected by code, re-read"]
    subgraph In["1. In the window on this call"]
        A["Always-on set<br/>identity, limits, tools"]
        P["Per-call set<br/>task, state, facts"]
    end
    M["The model reads<br/>the whole input"]
    F --> B
    T --> B
    K --> B
    B --> P
    A --> M
    P --> M
    M -->|"state the next step needs, written down"| F
    style In fill:#e3f2fd
    style Out fill:#fff9c4
    style M fill:#5a5a8a

Figure: The three decisions on every call: what is in the window (an always-on set and a per-call set), what lives outside it (files, records, a knowledge service), and how the outside is brought in. The arrow back is the model writing down the state the next step needs.

The numbers in the figure are the three decisions. The arrow back from the model is the one most often missing: whatever the next step needs and nobody wrote down is gone from the next call.

When nobody makes those decisions, the harness makes them by default: everything stays in, everything is resent, nothing is written anywhere else. The failures below come from that default.

The three decisions are this site's way of putting it. The summary you will meet most often elsewhere is LangChain's four strategies (2025-07-02): write context outside the window, select what to pull in, compress what stays, isolate work in separate windows. They map onto the three decisions: write is the second decision, select is the third, and compress and isolate are ways of making the first. How an Agent Builds Its Context puts every working technique behind those words in one table.

Five Ways Context Fails, in Brief

Read enough calls and the failures fall into five kinds. The five are this site's grouping, not a standard list: other writers name them differently, and When Context Turns Against You maps them onto the public terms. Each is something wrong with what the call carried, not with the model.

  • Missing. The fact was never in the window, or a compaction dropped it.
  • Stale. The fact is in the window and no longer true.
  • Drowned. The fact is present but buried under everything else.
  • Contradicted. Two versions of the truth are present at once.
  • Re-bought. The same tokens are paid for on every call, taking the room the others needed.

They all look like a model that got worse. When Context Turns Against You takes each kind with its evidence, the symptom it shows and where to look.

What Belongs in the Window

Two tests sort the window from its surroundings. The first comes from The alwaysApply Tax, a post about rules files loaded into every conversation: if someone asks "what's 2+2?", does this line need to be loaded? The second comes from The Three-Tier Context System, a post about where a project's notes should live: would losing this hurt if you started again from a fresh copy of the repository, with nothing but what is committed? The first empties the window; the second decides what the outside must hold.

In the window on every call Outside the window, brought in when needed How it comes in
Who the agent is and what it must never do Guidance for one file type, task or domain Loaded on a pattern, a description or a skill
The tools this job calls Connectors it might call Loaded for the task, or discovered on demand
The task and its frontier: what is done, what is next The full history, the dead ends, the superseded reasoning A progress file a fresh step re-reads
The decisions that bind this step Why each decision was made A decision record, read when the question reopens
The identifiers the next step acts on Everything the identifiers point to The file, the ticket, the record, fetched by id
Nothing fetched on speculation Knowledge that changes with the business A service with its own lifecycle, queried per call

The left column is small on purpose: it is re-bought on every call, so every line in it should pass the 2+2 test. The middle column is where durable state belongs, with the lifecycle and owner Externalize the Knowledge argues for: knowledge that changes should not ride a deploy to reach the agent.

The third column is the part most teams never write down. Each route fails in its own way: a resent history drowns, a tool call can be skipped, a retrieval can miss silently, a progress file can be out of date. Choosing the route is as much the discipline as choosing the column.

An Enterprise Illustration

Picture a vendor-risk team that runs an agent to draft answers to security questionnaires. It reads from a policy library, a ticketing system and a document store, through connectors a platform team approved one at a time. By the third week the complaints arrive together: it cited a retired version of the encryption policy, it lost track of which rows it had answered after a long session, and its context fills sooner than in week one. The proposal on the table is a larger model.

Read one of its calls instead. Most of the tokens are the tool schemas of connectors this agent never calls, re-bought on every call. Both versions of the encryption policy are in the history, one fetched on Monday and one on Thursday, and the model has been left to reconcile them silently. The compaction summary says the agent answered 40 of 61 rows and does not say which. Nothing here is a model fault, and a larger model would inherit every condition.

The fixes are all assembly. Scope the tool set to what questionnaires need. Fetch policy from the library by version on each call instead of letting old copies ride in the transcript. Write the row ids to a progress file as each is answered, so the next step reads the file, not the summary.

When the Model Really Is the Fix

Context engineering is not a claim that the model never fails. If the call's input is clean and the answer is still wrong, the model is the suspect and a stronger one may be the fix. What Compaction Actually Destroys found a real model difference in one place: given a marker that said which identifiers mattered, the stronger model used it and a smaller one ignored it. That is a capability gap, not a context gap. The same stronger model still lost every URL at a compaction near a million tokens, so the gap is real and it does not make the model the fix at a boundary.

A bigger window is also sometimes the right answer: for short, single-agent tasks with no shared state, a long window is simpler and you should take it. The Files Are the Memory names the loop too short to rot and the rare task that needs its whole history. In all of these the always-on set is small, the history short, and nothing crosses a boundary, so the discipline has nothing to do.

A bigger window moves the boundary later; it does not remove it, and it admits more to drown in before it arrives.

And the discipline has costs the default does not. A fresh-context loop demands that every step write its state down. A knowledge service adds a round trip; Externalize the Knowledge reports 50 to 200 milliseconds per query in its setup. Scoping tools to the job adds a discovery step when the job needs one more. For an agent whose sessions are short and whose tools are few, those costs outweigh the benefit. Measure your own calls before deciding which side of that line you are on.

Where the Series Goes

This is the first of ten chapters, and together they make one journey. Four Kinds of Context sorts what a call carries by who may write it and how long it lives. Direction Is Not Law takes the first kind on its own: how a decision ends by supersession. Law Belongs in the Harness takes the second: why a hard rule belongs in a check the harness runs, not in prose. How an Agent Builds Its Context assembles the window call by call, shows what is cut when it does not fit, and gathers the techniques that keep it small. When Context Turns Against You takes the five failures above in depth, with a lab. Shared State Needs One Writer keeps context correct when several agents share it. Working Context Is Disposable takes the context each agent keeps to itself: rederived, written down before a boundary, and otherwise let go. Compaction at the Pivot curates the window at the moment the plan changes. Context Engineering in Practice runs the whole routine on one agent, from its first call to a store that outlives the session.

Several of the chapters work one problem from different sides. Facts, decisions and even the objective change while the work runs, and an agent must not go on working from a version that no longer applies because it is still in the window, or in a document it retrieved months ago. Freezing the context is not the answer, and neither is letting it drift. The craft is letting it change under control: each change dated, the old version kept, with a record saying what replaced it, and each kind of context with its own writer. That balance is hard, and much of this series is about striking it. This site keeps its own changes of mind that way, on Where My Thinking Changed.

What to Do Next

  • Read one call before you change anything. Take the largest call your agent made yesterday and split its input into its parts: system prompt, tool definitions, history, tool results. The biggest part decides what to fix first.
  • Put every always-on line through the 2+2 test. What fails it moves to a pattern, a skill or a per-task load.
  • Write identifiers down before a boundary. Paths, ids, ticket numbers and URLs go to a progress file, verbatim, as the work happens. After a compaction, re-read the file, not the summary.
  • Give changing knowledge a home outside the window. It lives in a service with its own owner and lifecycle, fetched by version on the call that needs it; and decide when each kind of tool result leaves the history, so stale copies stop riding.
  • Keep each call's input as the audit record. When compliance asks what the agent knew, the answer is the input of each call (or the provider's stored copy of the conversation), with the same retention rules as the data inside it.

Next: Four Kinds of Context, which sorts the pieces of a call's input by who may write each one and how long it lives. Related reading: Anatomy of a Turn for why everything is resent on every call; What Compaction Actually Destroys for what a boundary drops; Your Tool Schemas Are the Bloat and The alwaysApply Tax for the always-on cost; The Files Are the Memory and The Three-Tier Context System for what lives outside the window; and Externalize the Knowledge for giving changing knowledge a lifecycle.