Keep the loop's context curated as it grows.
1. Make server-side compaction the default. For most long-running conversations it is the primary strategy. Reach for the fine-grained controls below only when you need to decide exactly what gets cleared and when.
2. Clear old tool results in heavy tool-use loops. Agentic workflows that call many tools accumulate results the model will never need again. Clear tool results that are superseded (an earlier search result replaced by a better one, intermediate file reads) while keeping the results the current plan depends on.
3. Clear thinking blocks deliberately. When using extended thinking, thinking blocks pile up fast. Clear older thinking blocks while preserving recent ones if the current reasoning builds on them. Dropping all thinking history mid-task can make the model repeat reasoning it already did.
4. Never clear what the next step needs. Before clearing, check the upcoming tool calls against the blocks you plan to drop. Clearing a tool result the next call references forces a re-fetch, which costs more than keeping it.
5. Combine with caching, carefully. Cached prefixes and cleared blocks interact: clearing inside a cached region invalidates the cache after that point. Put rarely-cleared content (system instructions, stable docs) in the cached prefix and the churn (tool results) after the last cache breakpoint.
6. Log what you clear. Record which blocks were cleared and when, per conversation. When a loop goes wrong, the clearing log is the first place to check: the model may be missing context you dropped.