---
title: "Tool result clearing pattern for AI agents | Agentic Pattern Language"
description: "Replace old tool results in the history with a short placeholder once the agent has used them. Sourced from Yang et al., Lindenbauer et al., and Manus."
url: https://agenticpatternlanguage.com/patterns/tool-result-clearing/
---

15 [One agent](https://agenticpatternlanguage.com/#one-agent)

# Tool result clearing

Replace old tool results in the history with a short placeholder once the agent has used them.

Also called Observation masking

Yang et al., Lindenbauer et al., Manus, LangChain, Anthropic

[How to read this](https://agenticpatternlanguage.com/notation/)

## Part of

* [Agent loop](https://agenticpatternlanguage.com/patterns/agent-loop/)

## Alternatives

* [Compaction](https://agenticpatternlanguage.com/patterns/compaction/)

## The problem

Old tool results, such as file contents or search results, keep filling the context after the agent has used them.

> Older tool results (such as file contents or search results) are no longer needed once Claude has processed them.

Anthropic [Context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing)

> Observations can be huge, especially when agents interact with unstructured data like web pages or PDFs.

Manus [Context Engineering for AI Agents: Lessons from Building Manus](https://manus.im/blog/Context-Engineering-for-AI-Agents-Lessons-from-Building-Manus)

## Therefore

> the structure and order of the agent’s interaction history is preserved, but the content of old observations are replaced with a one-line placeholder.

Yang et al. [SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering](https://arxiv.org/abs/2405.15793)

> A natural baseline approach directly targets verbose environment observations through observation masking strategies that explicitly omit tool outputs.

Lindenbauer et al. [The Complexity Trap: Simple Observation Masking Is as Efficient as LLM Summarization for Agent Context Management](https://arxiv.org/abs/2508.21433)

## In use

LangChain Deep Agents

> As the session context crosses 85% of the model’s available window, Deep Agents will truncate older tool calls, replacing them with a pointer to the file on disk and reducing the size of the active context.

LangChain [Context Management for Deep Agents](https://blog.langchain.com/context-management-for-deepagents/) Jan 28, 2026

Manus

> the content of a web page can be dropped from the context as long as the URL is preserved, and a document's contents can be omitted if its path remains available in the sandbox. This allows Manus to shrink context length without permanently losing information.

Manus [Context Engineering for AI Agents: Lessons from Building Manus](https://manus.im/blog/Context-Engineering-for-AI-Agents-Lessons-from-Building-Manus)

## Where it breaks

Clearing breaks the prompt cache, and a fixed rule ignores which results the agent still needs.

> Tool result clearing: Invalidates cached prompt prefixes when content is cleared.

Anthropic [Context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing)

> Observation Masking employs a fixed-size rolling window that is agnostic to the relevance or staleness of past observations (e.g., retaining a file’s content after it was modified).

Lindenbauer et al. [The Complexity Trap: Simple Observation Masking Is as Efficient as LLM Summarization for Agent Context Management](https://arxiv.org/abs/2508.21433)

> From a logical standpoint, any irreversible compression carries risk.

Manus [Context Engineering for AI Agents: Lessons from Building Manus](https://manus.im/blog/Context-Engineering-for-AI-Agents-Lessons-from-Building-Manus)

## Sources

1. [SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering](https://arxiv.org/abs/2405.15793) Yang et al.
2. [The Complexity Trap: Simple Observation Masking Is as Efficient as LLM Summarization for Agent Context Management](https://arxiv.org/abs/2508.21433) Lindenbauer et al.
3. [Context Engineering for AI Agents: Lessons from Building Manus](https://manus.im/blog/Context-Engineering-for-AI-Agents-Lessons-from-Building-Manus) Yichao 'Peak' Ji, Manus
4. [Context Management for Deep Agents](https://blog.langchain.com/context-management-for-deepagents/) LangChain, Jan 28, 2026
5. [Context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing) Anthropic

Added Nov 14, 2026
