Context engineering
Updated 2026-09-14
Questions this answers
- What is context engineering, and how is it different from prompt engineering?
- Why does my agent get worse the longer it runs?
- What is context rot?
- People say prompt engineering is dead. What replaced it?
- How do I decide what to put in the model's context?
The Fix
Context engineering is the practice of deciding what a model sees on each call: the system prompt, the user's message, retrieved documents, past conversation, tool definitions, whatever the agent remembered. Prompt engineering is one slice of that, the wording of the instruction. Context engineering is everything around it, plus the discipline of curating that pile so the model gets what it needs without drowning in what it doesn't.
The failure mode has a name: context rot. A model has a fixed amount of room to think in, its context window, measured in tokens, and quality does not hold steady as you fill it. As the window fills with old turns, stale files, and tool output nobody needs any more, answers get worse and hallucinations get more frequent. Chroma's research team measured this across frontier models and found performance degrades well before the window is technically full. Anyone who has watched a long chat session slowly lose the plot has seen it happen.
It matters most for agents. A single question is easy to get right, but an agent running a long loop keeps piling up history and tool output, and a bloated or noisy context quietly makes it dumber. Anthropic frames context engineering as managing that limited window on purpose, deciding what earns a spot and what gets dropped.
When to Use It
The term matters most once you're building agents or multi-step systems rather than firing off single prompts. If your agent starts strong and drifts as a session drags on, that's usually a context problem, too much noise crowding out the signal, and the fix is curation rather than a cleverer prompt.
Three habits do most of the work, and none of them need a framework. Be intentional about what goes in, so attach the two files that matter instead of the folder. Start a new chat for a new topic, because carrying a finished task into an unrelated one is pure noise. Ask for a summary, then start a fresh thread with it, which keeps the conclusions and drops the transcript that produced them. In Claude Code, /compact does that third one for you, and you can tell it what to keep.
For one-off chats you rarely need to think about any of this. For anything long-running, it's most of the game.
Best Practices
Anthropic: Effective context engineering
anthropic.com
Anthropic on curating the context window, and why it beats prompt tweaking for agents.
Chroma: Context rot
research.trychroma.com
Measures how model performance degrades as the context window fills, across frontier models.
Context engineering: a practical guide
sourcegraph.com
Context engineering applied to real AI agents.