curiosity

Article · Context engineering

What is context engineering?

Context engineering is choosing what a language model sees at each step: its instructions, the records it retrieves, the results of its tools and what it remembers. It also decides what stays out. A model works only with what is in its context window, and a fuller window is not a better one.

Topic Context engineering Reading time 8 min References 7 Updated October 2026

In short

Context engineering decides, for every call to a language model, which tokens it gets to read. Those tokens are the system instructions and the tool definitions. They are also the records a search returned, earlier tool results, notes the model kept and the conversation so far.

Prompt engineering is one part of it: writing the instruction well. Retrieval is another part: finding the records that might matter. Context engineering is the decision between them. Which of those records go in, in what form, next to what, and which earlier material is taken out again to make room.

From prompts to context

The term spread in June 2025. Simon Willison collected the posts that started it. Shopify’s Tobi Lutke liked that it names “the art of providing all the context for the task to be plausibly solvable by the LLM.”

The change in name follows a change in the work. A prompt for a single answer is written once. An agent runs in a loop: it calls a tool, reads the result and calls another, and each turn adds to what the model sees. The question stops being how to phrase the request. It becomes what the model should be looking at on turn 12.

Anthropic’s engineering team describes context engineering as what prompt engineering grows into once models work over many turns. Its guiding rule is to “find the smallest set of high-signal tokens that maximize the likelihood of your desired outcome.”

What competes for the window

Every model has a context window: a limit, in tokens, on what one call can read. Everything below shares it, on every call:

  • Instructions: the system prompt, and the rules that hold for this task.
  • Tool definitions: each tool’s name, description and parameters, sent whether or not the tool is used.
  • Retrieved records: tickets, part records, supplier notices, pages of a manual.
  • Tool results: what each call returned, from the first turn on.
  • Memory: notes the model wrote earlier, or facts kept from past conversations.
  • History: the person’s messages and the model’s own replies.

Each of these is a decision someone made, or forgot to make. A tool result left in the history after it was used still takes room on every later call.

How it works

One step, one window

A service engineer asks a question. Search finds far more than the model should read. Pick a step to stop the drawing and read it.

One step’s context window A service engineer asks whether pump P-7 has failed this way before. Search finds 40 tickets. The 12 on other teams are left out, and so are 25 weaker matches and the bodies of six skills. The window holds the instructions, the question, 3 tickets as ids and summaries, and six skill names. The model answers from the ticket that matched and cites it. QUESTION · A SERVICE ENGINEERHas pump P-7 failed this way before?SEARCH · 40 TICKETSIN THE WINDOWLEFT OUTInstructions and the question12 tickets on other teams3 tickets, ids and summaries25 weaker matches6 skill names, one line each6 skill bodies, until readANSWERNot yetANSWER · 1 SOURCE CITEDYes, in March: ticket T-4410
One step’s context window A service engineer asks whether pump P-7 has failed this way before. Search finds 40 tickets. The 12 on other teams are left out, and so are 25 weaker matches and the bodies of six skills. The window holds the instructions, the question, 3 tickets and six skill names. The model answers from the ticket that matched. QUESTIONHas pump P-7 failed this way before?40 TICKETSIN THE WINDOWInstructions and the question3 tickets, ids and summaries6 skill names, one line eachLEFT OUT12 tickets on other teams25 weaker matches6 skill bodies, until readANSWERNot yetANSWER · 1 SOURCE CITEDYes, in March: ticket T-4410
  1. 01

    A question arrives

    A service engineer asks whether pump P-7 has failed this way before. The window holds the instructions and the question.

  2. 02

    Check access first

    Search finds 40 tickets. 12 belong to teams the engineer is not on, so they never reach the model.

  3. 03

    Keep what answers

    Of the 28 left, 3 go in, as ids and short summaries. The rest stay in the graph.

  4. 04

    Names, not bodies

    Six skills go in as a name and one line each. A body is read only when the model asks for it.

  5. 05

    The model answers

    It answers from the ticket that matched and cites it. Nothing it did not need took up room.

Why more context is not better

Context windows now reach millions of tokens, so it is tempting to send everything. Chroma tested 18 models in July 2025 on tasks kept simple on purpose, changing only the length of the input. In one test the models answered questions about a long chat history. Given only the relevant parts, about 300 tokens, every model did markedly better than with the full history of about 113,000 tokens. The report found that performance “grows increasingly unreliable as input length grows.”

Position matters too. Liu and coauthors showed in 2023 that models use information best at the start or end of a long input. They use it worst in the middle. Anthropic’s post calls the general effect context rot: every added token draws on the model’s limited attention.

There is a plain cost as well. Every token in the window is sent again on every call of the loop, so a crowded window costs something on every turn.

The techniques that work

  • Retrieve late, by reference. Keep ids, paths and queries in context, and let the model fetch a record when it needs it. Anthropic calls this just in time context.
  • Return less from tools. A tool that returns ids and a few fields leaves room. A tool that returns a whole document fills the window with text the model may never use.
  • Disclose step by step. Give the model names and one line descriptions up front, and the full text only when it asks.
  • Compact long runs. Near the limit, clear old tool results and replace the history with a summary. Keep the latest result.
  • Keep notes outside the window. The model writes progress to a file or a record and reads it back after a reset.
  • Split the work. A sub-agent explores in a window of its own and hands back a short summary. Anthropic reports those summaries are often 1,000 to 2,000 tokens.

Over a long task

Filling up, then compacting

Each turn of an agent adds to the window. Compaction clears what the model has already used and keeps a summary in its place.

A context window over a long task A window of 20 units. Turn by turn it fills with the instructions, messages and tool results: 7 units, then 13, then 19. Compaction clears the old tool results and keeps a short summary and the latest result, 10 units. The fourth turn goes on with room to spare. CONTEXT WINDOWLIMITTurn 1 · 7 of 20 usedTurn 2 · 13 of 20 usedTurn 3 · 19 of 20 usedCompacted · 10 of 20 usedTurn 4 · 15 of 20 usedINSTRUCTIONSMESSAGESTOOL RESULTSSUMMARYFREE
A context window over a long task A window of 20 units fills turn by turn with instructions, messages and tool results, up to 19 units. Compaction clears the old tool results and keeps a summary and the latest result. The fourth turn goes on with room to spare. CONTEXT WINDOWLIMITTurn 1 · 7 of 20 usedTurn 2 · 13 of 20 usedTurn 3 · 19 of 20 usedCompacted · 10 of 20 usedTurn 4 · 15 of 20 usedINSTRUCTIONSMESSAGESTOOL RESULTSSUMMARYFREE
  1. 01

    The window starts small

    The instructions, the task and the result of one search.

  2. 02

    Each turn adds to it

    A second tool call and its result. Earlier results stay unless something removes them.

  3. 03

    Near the limit

    After three turns the window is almost full, mostly with results the model has already read.

  4. 04

    Compact it

    Old tool results are cleared, and the history becomes a short summary. The latest result stays.

  5. 05

    Room to go on

    The fourth turn runs with the summary, the latest result and room for the next step.

How it goes wrong

  • Everything goes in. The answer was in the window, in the middle of 40 near matches, and the model picked a near match.
  • Records the person may not open. Whatever is in the window can end up in the answer. The access check belongs before a record is added, which is what permission-aware retrieval means.
  • Text read as orders. A ticket or a file in the window can carry instructions, and the model reads them like any other text. That is prompt injection.
  • Stale memory. A note kept from last month states a fact that has since changed, with nothing to say when it was written.
  • Compaction that loses the point. A summary drops the one detail that mattered three turns later.
  • Overlapping tools. Two tools that do nearly the same thing cost room in every call and leave the model unsure which to use.

How to evaluate it

Six questions, asked of a real run rather than a demo:

  1. Can you see the exact context of any call: every instruction, record and tool result the model read?
  2. How much of that context did the answer use?
  3. Was every record in it one the person asking may open, checked before it went in?
  4. What happens at the limit: an error, silent truncation, or a summary you can read?
  5. Do tool results return ids and short fields, or whole documents?
  6. Does every remembered fact say where it came from and when?

The answers depend on the data underneath. A model can only be handed the right three records if something already knows which records relate to the question. That is the job of a context graph.

How Curiosity handles it

Curiosity Studio starts from records connected in one typed graph, from more than 70 systems, with the access rights of their source. The built in search and read tools run as the person who asked, so a record they may not open never reaches the window.

Skills follow the step by step pattern. The documentation describes how an assistant is told each skill’s name and one line description up front. It reads the body only when it needs it. The agent loop guide suggests tools that return ids and short fields rather than whole documents, and fewer than about 10 tools per agent.

The model is a setting, from any of the providers Studio supports. Each provider declares its context window. The chat uses it to decide how much history and context to send, as the custom provider page describes. The AI agents page has the developer view.

FAQ

Questions people ask

What is the difference between prompt engineering and context engineering?

Prompt engineering is writing the instruction. Context engineering decides everything the model reads on each call: instructions, tool definitions, retrieved records, tool results, memory and history. It matters most for agents, whose context changes with every turn.

Is a bigger context window better?

A bigger window raises the limit, not the quality. Studies such as Chroma’s 2025 report found models less reliable as the input grows, even on simple tasks. A small window holding the right records usually beats a large one holding everything.

What is context rot?

The loss of accuracy as a model’s context grows: the more tokens in the window, the worse the model recalls and uses what is in it. Anthropic uses the term, and Chroma measured the effect across 18 models in July 2025.

What is compaction in an AI agent?

Clearing what a long run no longer needs, such as old tool results, and replacing the history with a summary when the context window is nearly full. The agent then continues with the summary and its latest results.

Your data. Your infrastructure.

Grounded, not guessed.