What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
To shrink an agent’s context safely, prune tool-result payloads by a deterministic policy—not by editing reasoning artifacts or blindly deleting old messages. Preserve the call-and-result structure needed to continue the run, including identifiers, ordering, arguments, and any outputs later steps still rely on.
What you can prune—and what must stay intact
Treat context pruning as a data-integrity boundary. A tool result may be large, but it can also be evidence that a later step depends on. Its age alone does not make it safe to remove.
As an Amazon Associate I earn from qualifying purchases.
- Potentially prune: results that are stale, duplicated, or outside an explicit retention allowlist, after confirming they are not referenced by later steps.
- Keep: assistant reasoning items and provider-native reasoning artifacts, tool calls and their matching outputs, call IDs, ordering metadata, arguments, and any result needed by downstream work.
- Do not treat a summary as equivalent by default: if you summarize an older result, keep the summary outside the active call sequence and verify that it retains whatever later steps require.
OpenAI’s official reasoning guidance recommends leaving items between the last user message and function-call output untouched when truncating, and passing reasoning items, function-call items, and outputs together when several functions run consecutively. This preserves the structure around a live interaction; it is not permission to rewrite provider-specific reasoning data.
Use a deterministic pruning policy
Make pruning depend on explicit rules that can be reviewed and replayed, rather than asking a model to decide ad hoc which history to discard. A practical policy assigns each result a tool name, call ID, timestamp, turn, and downstream references, then applies one of three outcomes:
#1 Best Overall
| Decision | When to use it | What to retain |
|---|---|---|
| Retain | The result is part of the active call sequence, referenced later, or needed to reconstruct a decision. | The original result and its associated call metadata. |
| Summarize outside the active chain | An older result is no longer active, but a concise record may still help later work. | A clearly marked summary and the metadata needed to identify the original call. |
| Drop after a safe horizon | The result is stale or duplicated, has no downstream references, and falls outside the policy’s retention window. | A pruning decision record; retain the raw history separately when policy permits. |
Set the safe horizon and any tool allowlist or denylist explicitly. There is no universal age or token threshold in the cited provider guidance that makes a result safe to delete.
Prune in a replay-safe order
- Label each tool result. Record its tool name, call ID, timestamp, turn, and known downstream references.
- Classify it by policy. Choose retain, summarize outside the active chain, or drop after the safe horizon. Make the decision deterministic and auditable.
- Protect the active sequence. Keep all items from the latest user message through the matching function-call output intact unless the provider explicitly permits another transformation.
- Preserve provider-native state. Keep reasoning items, thinking blocks, or thought signatures in the form required by that provider; do not partially edit them.
- Keep calls joinable. Preserve call IDs, ordering, and arguments so each retained output can be matched to the request that produced it.
- Record the change. Log the rule decision and original hash, and retain raw history in durable storage if your policy permits.
- Replay and check. Verify that each remaining result is adjacent to, or correctly associated with, its call and that no required result is missing.
Provider-specific requirements differ
| Provider or approach | Preserve | Practical caution |
|---|---|---|
| OpenAI | Reasoning context and the ordered sequence around function calls, using the documented replay mechanisms. | Reasoning tokens are not exposed as ordinary text. Do not assume you can inspect or safely edit them as plain text. |
| Anthropic | Every thinking block used during tool use, complete and unmodified. | Anthropic’s documentation says: “Pass every thinking block back to the API complete and unmodified.” Older thinking blocks may be filtered according to model policy, but that does not authorize partial edits to a block being passed back. |
| Google Gemini | Thought signatures and their associated function-call context. | Google Cloud describes a thought signature as a “save state” for resuming after a function result. Preserve it consistently; partial context can degrade performance. |
| OpenClaw-style local pruning | Tool-call associations and the raw history separately from any trimmed replay view. | Tool-result trimming can use allow or deny lists. Older processed image blocks may be replaced in a replay view while raw history remains preserved, so do not confuse the two representations. |
Test whether the pruned history still works
Token reduction is only useful if the agent can still continue from the replayed context. Compare implementations on six dimensions: what content may be removed, whether pruning is deterministic or model-generated, how reasoning state is represented, whether raw history is retained, token reduction and latency, and what happens if a required result is missing.
Rank #2
- Replay a multi-call sequence and confirm every output still matches the correct call.
- Test a later step that references an older result; the policy should retain the result or make the dependency failure explicit.
- Test a missing required result. Fail closed or recover from durable history rather than silently continuing with an incomplete context.
- Compare token use and latency on the same workload, while checking task quality and replay integrity.
The Squeez research paper on arXiv (2026) reports 0.86 recall, 0.80 F1, and 92% input-token removal in its coding-agent evaluation. Those are results for that paper’s evaluation, not a general production guarantee or a promise that a particular pruning policy will achieve the same reduction.
Keep the objective narrow
The goal is not to preserve every old payload in the active prompt, nor to compress the reasoning state itself. It is to remove expendable tool data under a rule while maintaining the causal links and provider-specific state required to continue the run faithfully.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




