Prompt engineering optimised the message. Context engineering optimises the session: what is in the window at every step, why it is there, and what it displaced to get in.

That distinction matters because a context window is not a container to fill. It is a budget with three simultaneous prices, and only one of them shows up on an invoice.

Three prices

Money. Input tokens are cheap per token and the volume is enormous. A single agent session on a real repository can read the same file a dozen times across a dozen turns, each time re-sent in full with the whole history attached. The invoice is a lagging indicator; it tells you what you already spent, not what was worth spending.

Latency. Every turn pays to re-read the window. A bloated session gets slower in a way that feels like the model thinking harder, when it is mostly the harness moving a larger payload. That latency is what makes the human stop waiting and start batch-approving.

Attention. This is the expensive one and it does not appear anywhere. Instructions at the top of a long session get diluted by everything that arrives after them. A rule stated once at turn 1 is weakly present at turn 40. Constraints compete with stale tool output, abandoned branches of reasoning, and the agent's own earlier mistakes - which it will happily read as precedent.

What actually competes for the window

I think of it as layers, each with a job and a budget:

Layer What it holds Failure if unbounded
Standing instructions Rules that must survive the whole session Diluted into background noise
Project facts Architecture, conventions, invariants Re-derived every run, inconsistently
Task statement What "done" means, right now Drifts as the session accumulates tangents
Working set The files and outputs needed for this step Whole repo pasted "just in case"
History What happened so far Old failures quoted as precedent
Tool output Raw command results Uncompressed logs drowning the signal

The layers fail differently, and they need different fixes. Standing instructions need to be re-stated, not just stated. Project facts should live in the repo as files, not in a prompt that only exists in one person's session. Tool output should be compressed at the boundary - the agent rarely needs all 4,000 lines of a build log, it needs the error and the file.

Practices that survived contact

Durable artifacts beat instructions. A CONVENTIONS.md, an architecture note, an ADR directory versioned with the code, reviewed like code. Anything the agent needs to know twice belongs in a file, not in a chat message. This is the highest-leverage change I have made, and it is not really an AI technique at all.

Retrieve on demand, never "just in case". If a file might be relevant, give the agent the ability to open it, not its contents. The ability costs nothing; the contents cost every turn afterwards.

Compress at the boundary. Run the command, keep the failure, drop the noise. Summarise a long file into a map - function names and line ranges - and let the agent fetch what it needs.

One task per session. The single biggest source of context pollution is yesterday's task, still sitting in the history, still being treated as context for today's. Fresh session, explicit briefing, done.

Kill the branch you abandoned. Half-finished reasoning is expensive: it reads as prior commitment, and the agent will build on it rather than reconsider.

The practical test

Before adding anything to the window, ask the boring question: if this were missing, would the agent do the wrong thing? If the answer is "probably not", it is decoration, and decoration is charged at full price on every subsequent turn.

The teams that get good at this are not writing cleverer prompts. They are building environments where the right context is cheap to find and the wrong context never arrives.