Study FAQ
How do I prune tool output and compact Claude context without losing important evidence?
Also asked as 2
- When should I drop old tool results versus summarize a long Claude conversation?
- What should a Claude agent preserve when compacting a long-running task?
Answer
Prune individual tool results when their details have served their purpose. Compact when a continuing task needs a smaller representation of a substantial stretch of history. In both cases, keep the facts, open questions, and source locators needed to check or continue the work.
For a bulky log or search result, retain the raw artifact outside active context when policy permits. Extract verified facts and identifiers with provenance, then remove irrelevant detail only after checking what the next step needs. Preserve constraints based on their authority and relevance even if they are old.
A compacted handoff should record the current objective, completion checks, confirmed decisions, unresolved blockers, safety and authorization limits, workflow state, and authorized evidence locators. Version the summary with its source range, invalidate it when facts change, and test a representative resume from the summary. If a critical decision disappears, adjust what the handoff preserves or retrieve the original.
On the Claude API, context editing can clear eligible tool results or thinking blocks according to rules, while compaction replaces older turns with a summary. On-demand compaction and compaction at a token threshold are documented beta options. Check supported models, providers, triggers, and header requirements for the exact strategy, and retain required records externally before enabling automatic clearing.
Full explanation
Context and Memory Management for Claude Applications and Agents
Study guide · CCDV-F
Read the full explanation