Agent Wealth HubFree public resources
中文 EN العربية

Back to catalog / Agent context

Clear old tool results after processing

Keep recent results while removing re-fetchable payloads from long-running context.

Goal

Reduce repeated context cost from large tool outputs in long tool workflows.

Steps

  1. Confirm the target result is safely re-fetchable and is not a recent result needed for the current decision. [toolclear]
  2. Configure context_management.edits with type="clear_tool_uses_20250919", an input_tokens trigger, recent tool_uses to keep, and clear_at_least. [toolclear]
  3. Inspect context_management.applied_edits for cleared calls and tokens freed; let the agent reread a tool if the original content is needed later. [toolclear]

How to verify

Compare token trajectories on a multi-turn synthetic file-read task; confirm tool-use pairing stays intact, recent results remain, and the final synthesis is correct.

Troubleshooting

If clearing does not trigger, check the beta header, model support, and trigger threshold; if an old result is needed, call its source tool again rather than assuming it can be restored.

Permissions

Prerequisites

Permissions

Limitations

Clearing removes old tool_result bodies; the model must call a tool again if needed. It is neither whole-history summarization nor persistent memory.

Pinned upstream source

https://github.com/anthropics/anthropic-cookbook/blob/9c1e493ddd2b82df399d2a61b9c806c539e18be6/tool_use/context_engineering/context_engineering_tools.ipynb

Repository
anthropics/anthropic-cookbook
File path
tool_use/context_engineering/context_engineering_tools.ipynb
Pinned commit
9c1e493ddd2b82df399d2a61b9c806c539e18be6
Source checked
2026-10-14 · Reviewed against the pinned upstream source

Repository metrics

These values describe the upstream repository, not popularity or likes for an individual skill or playbook.

Stars
Not collected
Forks
Not collected
Observed at
Not collected

No metrics snapshot is available yet.

License: MIT

Main topic

Take a coding Agent change from context to verification

Related resources