85 agentic tools audited for security incidents · Talk to the lab →
MotionticBook a call
Glossary

What is context editing?

Context editing is the automatic removal of stale content, such as old tool results or earlier reasoning blocks, from an agent's context window as it grows, so a long run keeps going without summarising the whole history.

Most of an agent's context is tool output it has already acted on: search results it has read, files it has already edited, query rows it has already summarised. Context editing removes that material once it is stale, instead of summarising everything or stopping when the window is full.

Anthropic introduced context editing on its developer platform in September 2025, alongside a file-based memory tool. On an internal agentic search eval, context editing alone improved performance by 29%, and by 39% combined with the memory tool. On a 100-turn web search eval it let agents finish workflows that otherwise failed from context exhaustion, while cutting token use by 84%.

How context editing works

  • Tool result clearing

    The oldest tool results are replaced with a placeholder once the context passes a threshold. Tool call inputs can optionally be cleared too.

  • Thresholds and limits

    In Anthropic's API, clearing triggers at 100,000 input tokens by default and keeps the three most recent tool uses; both are configurable, and named tools can be excluded.

  • Reasoning block clearing

    A second strategy removes thinking blocks from earlier assistant turns, keeping a set number of recent ones.

  • Applied on the server

    Edits are applied before the prompt reaches the model, while the client keeps the full, unedited history.

Context editing, compaction and memory

Compaction summarises the history and replaces it; context editing deletes specific content and leaves the rest untouched. Anthropic's documentation now treats server-side compaction as the primary strategy for most long conversations, and context editing as the option for finer control over what is removed.

Context editing pairs naturally with memory. When the context nears the clearing threshold, the agent can be warned and save anything it still needs to memory files before the tool results disappear, then read them back later.

The prompt caching trade-off

Clearing content changes the prompt, so it invalidates the cached prefix from that point. Anthropic's API offers a minimum amount to clear on each pass, so that every clear removes enough tokens to justify the cost of writing a new cache entry.

How Motiontic's engineers apply it

Motiontic's engineers set clearing thresholds from eval runs, exclude tools whose results stay relevant for the whole task, and give the agent a memory file for facts it must keep. The aim is a context that holds what the agent needs next, not everything it has seen.

Context editing compared with compaction

Context editing compared with compaction
Context editingCompaction
What happens to old contentSpecific items are clearedThe history is summarised and replaced
What survivesEverything not cleared, word for wordA summary of what came before
ControlFine: which tools, how many to keep, when to triggerCoarse: when to summarise and what to stress
Typical useTool-heavy runs with bulky, short-lived resultsLong conversations that need continuity
Cache impactInvalidates the cache from the cleared pointReplaces the prompt after each summary

Common questions

Does context editing lose information?

Yes, from the model's view: cleared results are gone from its context, though the client keeps the full history. Excluding important tools and saving key facts to memory first limits the loss.

What is the difference between context editing and compaction?

Context editing removes specific items, such as old tool results, and leaves everything else as it was. Compaction rewrites the history into a summary.

Does context editing break prompt caching?

It invalidates the cache from the point where content was cleared. Clearing in larger batches, rather than a little at every turn, keeps the cost of new cache writes down.

Running agents that have to hold up?

Describe the agent, the systems it touches and what it must never get wrong. The first call is with a lab engineer, who will say plainly whether it is ready for production, and whether Motiontic is the right team.