Guides

What Is Context Engineering? Why It Matters More Than Prompts for AI Agents

Context engineering explained: what it is, why more context makes AI worse, the four core techniques, and how it decides whether AI agents work.

  • By Incube Team
  • Published
  • 10 min read
Illustration for an explainer on context engineering, showing how information flows into an AI model's context window
Quick answer

Context engineering is the practice of deciding exactly what an AI model sees at each step of a task: instructions, tools, retrieved documents, memory and history. It matters because models get less accurate as context grows. The core techniques are writing notes outside the window, selecting only relevant information, compressing old turns and isolating sub-tasks in separate agents.

On this page
  1. Key takeaways
  2. What is context engineering, in plain English?
  3. How is context engineering different from prompt engineering?
  4. Why does more context make AI models worse?
  5. What are the four ways context fails?
  6. What are the core context engineering techniques?
  7. What did Manus learn about context the hard way?
  8. Do AGENTS.md and CLAUDE.md files actually help?
  9. Why does context engineering decide whether AI agents do real work?
  10. How can you start applying context engineering this week?
  11. Frequently asked questions

Key takeaways

  • Context engineering is deciding what an AI model sees at every step, not just how one prompt is worded.
  • More context often means worse answers: studies from Stanford researchers and Chroma show accuracy drops as inputs grow.
  • The four core techniques are write, select, compress and isolate.
  • Stable prompt prefixes save money: Manus quotes a 10x price gap between cached and uncached input tokens.
  • For agents that do real work, most failures are context failures, so specialised agents with tightly scoped context are easier to make reliable.

Picture the smartest new hire you’ve ever had. Now picture handing them a 400-page binder on day one, with the actual task buried on page 237, three outdated policies, and a sticky note from 2019 that contradicts everything. They’d do worse work than a less brilliant colleague who got a clean one-page brief.

That, in one image, is why AI people stopped obsessing over prompts and started talking about context engineering. The model is rarely the weak link anymore. What we feed it is.

What is context engineering, in plain English?#

Context engineering is the practice of deciding exactly what an AI model sees at each step of a task: its instructions, the tools it can use, the documents it retrieves, its memory and the conversation so far. Anthropic’s engineering team defines it as the set of strategies for "curating and maintaining the optimal set of tokens" during inference, and calls it "the natural progression of prompt engineering" (Anthropic, September 2025).

Andrej Karpathy put it more poetically in mid-2025, describing it as the "delicate art and science of filling the context window with just the right information for the next step." LangChain, which quotes that line, borrows his analogy too: the model is the CPU, and its context window is the RAM.

So if a prompt is the question you ask, the context is everything on the desk when the question is asked. Including the mess.

How is context engineering different from prompt engineering?#

Prompt engineering is about writing one good instruction; context engineering is about managing the whole information flow around a model across many steps. A chatbot answering one question lives and dies by its prompt. An AI agent that runs for fifty tool calls, reads files, searches the web and remembers yesterday’s work lives and dies by its context.

Prompt engineeringContext engineering
Unit of workA single instructionEvery token the model sees, at every step
Typical settingOne-shot chat or a fixed templateMulti-step agents, tools, memory, retrieval
Main question"How do I phrase this?""What does the model need right now, and what should it not see?"
Typical failureVague or ambiguous wordingBloat, stale facts, contradictions, lost instructions
Who owns itWhoever writes the promptWhoever designs the system around the model

Cognition, the team behind the Devin coding agent, went as far as calling context engineering "effectively the #1 job of engineers building AI agents," as LangChain notes. Bold, but not wrong.

Why does more context make AI models worse?#

More context makes models worse because their ability to use information drops as the input grows, a problem now widely called context rot. Long context windows sold us a dream: just paste everything in. The research says otherwise.

  • Lost in the middle. A 2023 Stanford-led study found models perform best when the key fact sits at the beginning or end of the input, and "significantly degrade" when it is buried in the middle (Liu et al., TACL).
  • Context rot across 18 models. In July 2025, Chroma tested 18 LLMs, including GPT-4.1, Claude 4, Gemini 2.5 and Qwen3, and found that "model performance consistently degrades with increasing input length." Even a single distracting near-miss fact hurt accuracy (Chroma research).
  • The weird one. Chroma also found that models did better on shuffled, incoherent haystacks than on logically structured ones. Nobody fully knows why. It’s a good reminder that these systems don’t read like we do.

Anthropic frames this as an attention budget: every token you add draws it down a little, because transformers relate every token to every other token. Their advice is to find "the smallest possible set of high-signal tokens that maximize the likelihood of some desired outcome." Less, but better.

What are the four ways context fails?#

Drew Breunig’s widely cited June 2025 post names four failure modes that anyone running agents will recognise:

  1. Context poisoning. A hallucination or error gets into the context and is then referenced again and again, like a rumour that becomes office lore.
  2. Context distraction. The context grows so long that the model over-focuses on it and neglects what it learned in training. Breunig cites a Databricks finding that correctness began to fall at around 32,000 tokens for Llama 3.1 405B.
  3. Context confusion. Superfluous content, such as dozens of irrelevant tool definitions, leads to a low-quality answer. In one case he cites, an agent given 46 tools failed where the same agent given 19 succeeded.
  4. Context clash. New information contradicts older information in the same context. A Microsoft and Salesforce study he cites found an average performance drop of 39% when prompts were split across turns.

If you’ve ever watched an agent confidently repeat its own earlier mistake, you’ve met context poisoning. It’s the AI equivalent of "but that’s how we’ve always done it."

What are the core context engineering techniques?#

The core techniques fall into four moves: write, select, compress and isolate. LangChain’s July 2025 framework gave the field a shared vocabulary for them.

Diagram of the four moves of context engineering: write, select, compress and isolate, each feeding the model's context window
The four moves of context engineering. Diagram: Incube, based on LangChain’s framework.

Write: give the agent a notebook

Writing means saving information outside the context window so the agent can come back to it. Anthropic calls this structured note-taking: Claude Code keeps a to-do list, and agents can maintain a NOTES.md file that survives long tasks. Manus goes further and treats the file system as "the ultimate context": unlimited, persistent and directly operable by the agent (Manus, July 2025). We covered the tooling side of this in our roundup of GitHub repos for AI agent memory.

Select: pull in only what this step needs

Selecting means retrieving the right facts, tools and examples just in time, rather than preloading everything. Anthropic describes agents that hold "lightweight identifiers" such as file paths or saved queries and load the data only when needed. It’s the difference between carrying the whole library and carrying the call numbers.

Compress: summarise before you drown

Compressing means keeping only the tokens the task still needs. Claude Code auto-compacts a conversation once it passes 95% of the context window, keeping decisions and open bugs while dropping redundant tool output. Anthropic’s tip is to tune summaries for recall first, then trim for precision.

Isolate: give sub-tasks their own clean desk

Isolating means splitting work across sub-agents, each with a fresh context. Anthropic notes a sub-agent might burn through tens of thousands of tokens exploring, then hand back a summary of often just 1,000 to 2,000 tokens. The catch: LangChain reports Anthropic’s multi-agent research system used up to 15 times more tokens than chat. Clean desks aren’t free.

What did Manus learn about context the hard way?#

Manus, the general-purpose agent startup, rebuilt its agent framework four times and published the scars. Peak Ji’s post is the most practical thing written on the topic, and a few lessons stand out.

Design around the cache. Manus sees an input-to-output token ratio of around 100:1, so input cost dominates. With Claude Sonnet, cached input tokens cost $0.30 per million versus $3 uncached, a 10x gap. Ji calls the KV-cache hit rate "the single most important metric for a production-stage AI agent." Practical upshot: keep the start of your prompt stable. A timestamp to the second at the top of your system prompt quietly breaks the cache on every call.

Bar chart comparing Claude Sonnet input prices quoted by Manus: 0.30 US dollars per million cached tokens versus 3 dollars uncached
Cached vs. uncached input pricing as quoted by Manus. Chart: Incube.

Recite the goal. A typical Manus task takes around 50 tool calls. To stop the agent forgetting its objective, it rewrites a todo.md file, pushing the goals to the end of the context where attention is strongest.

Keep the wrong turns in. Counter-intuitively, Manus leaves failed actions in the context. "Erasing failure removes evidence," Ji writes, and without evidence the model can’t adapt.

Don’t few-shot yourself into a rut. When reviewing 20 resumes, the agent started copying its own earlier pattern. Small, deliberate variation in formatting broke the spell.

Do AGENTS.md and CLAUDE.md files actually help?#

Only when they carry information the agent can’t find on its own. A 2026 study by Thibaud Gloaguen and colleagues evaluated repository context files for coding agents and found they "do not generally improve task success rates," while raising inference cost by over 20% on average (Gloaguen et al., arXiv). Agents did follow the instructions well. The problem was the content: generic repository overviews didn’t help, while notes on non-standard practices did.

That’s context engineering in miniature. A context file isn’t a welcome pack. It’s a list of things the agent would otherwise get wrong.

Why does context engineering decide whether AI agents do real work?#

Because an agent that does real work is mostly a context pipeline with a model in the middle. A March 2026 paper goes as far as calling context "the agent’s operating system," closing with the line "Whoever controls the agent’s context controls its behavior" (Vishnyakova, arXiv).

When we build specialised agents at Incube, this is where most of the engineering time goes, and it’s the part demos skip. Take an invoice processing agent. The model is the easy bit. The hard bits are context questions:

  • What does it see per invoice? The invoice, the matching purchase order and the vendor’s rules. Not the last 300 invoices.
  • What does it remember? Vendor quirks it has verified, written to a store it can query, not stuffed into every call.
  • What does it never see? Tools it doesn’t need for this step, so it can’t wander.
  • How do we know it’s right? Every extraction is checked against source data, exceptions go to a human, and each run is logged so a person can see exactly what context produced which decision.

That last point is why specialisation matters. A general assistant has to guess what’s relevant in a giant, shifting context. A specialised agent works in a narrow lane where the relevant context is known, tested and monitored, which is what makes reliable, verified output realistic rather than lucky. The same logic runs through our inbox triage agent and support resolution agent. If you’re new to the distinction, our guide to AI agents vs. chatbots vs. RPA is a good starting point, and our post on AI agent kill switches covers the human-control side.

How can you start applying context engineering this week?#

Start by auditing what your AI tools actually see, not what you think they see. A quick checklist:

  1. Print the full context of one real agent run and read it top to bottom. Most teams are surprised.
  2. Delete anything generic. If the model would know it anyway, it’s costing attention.
  3. Cut the toolbox. Anthropic’s test: if a human engineer can’t say which tool fits a situation, the agent can’t either.
  4. Stabilise the prefix so caching works, and move changing data to the end.
  5. Add a notebook (a to-do or notes file) for any task longer than a few steps.
  6. Log and review contexts behind wrong answers. Most "model errors" turn out to be context errors.

Here’s a question worth taking to your team: for the one workflow you most want to automate, can you write down exactly what information a person needs to do it well, and nothing more? If you can, you’ve done half the work of building an agent for it.

And if you’d rather have that agent designed, tested and run for you, with humans firmly in control, that’s what we do at Incube.

Frequently asked questions#

What is context engineering in AI?

Context engineering is the practice of curating everything a large language model sees when it runs: system instructions, tool definitions, retrieved documents, memory and conversation history. Anthropic describes it as finding the smallest set of high-signal tokens that make the desired outcome most likely. It is the natural next step after prompt engineering, and it matters most for AI agents that work across many steps.

What is the difference between prompt engineering and context engineering?

Prompt engineering focuses on wording a single instruction well. Context engineering manages the whole information flow around a model across many steps, including which tools it can see, what it retrieves, what it remembers and what gets summarised or removed. A chatbot depends mostly on its prompt, while a multi-step AI agent depends mostly on its context.

What is context rot?

Context rot is the drop in a language model’s accuracy as the amount of text in its context window grows. Chroma’s July 2025 study of 18 models, including GPT-4.1, Claude 4 and Gemini 2.5, found performance consistently degraded with longer inputs, and that even one distracting near-miss fact reduced accuracy. It is a gradual slope rather than a sudden cliff.

Do AGENTS.md or CLAUDE.md files improve coding agents?

Not by default. A 2026 study by Gloaguen and colleagues found repository context files did not generally improve task success for coding agents and raised inference costs by over 20% on average. Agents followed the instructions, but generic repository overviews did not help. Files were useful when they described non-standard practices an agent could not infer from the code.

How does context engineering make AI agents more reliable?

It limits what an agent sees to what the current step needs, keeps verified facts in memory it can query, and removes tools and data that invite mistakes. Teams like Incube pair this with checks against source data, human review of exceptions and logging of every run, so each decision can be traced back to the exact context that produced it.

Written by Incube Team

Incube designs, builds and runs specialized AI agents for operations teams. We write about what we see working, and what to watch out for, when you put agents to work.

Put your first agent to work

Start with one workflow, clear guardrails and a measured pilot. We handle the audit, the build and the running.

Start a Pilot

Keep reading