Tool-Output Pruning and Compaction
CoreApply context curation techniques: pruning, compaction, isolation, and retrieval · Difficulty 2/5
Explanation
Tool-Output Pruning
After a tool returns a large payload, keep only what later steps actually need; drop raw dumps from the ongoing history. A verbose tool result that was necessary to inspect once does not need to persist in full for the rest of the session.
Compaction
Periodically summarize older turns into a compact recap and continue from it, reclaiming budget while preserving the thread. This is how long agent sessions avoid drift -- rather than carrying the entire transcript forward indefinitely, the session's history is condensed into what still matters.
Compaction vs. Truncation
Compaction is not the same as truncation. Compaction summarizes to reclaim budget while preserving the thread; truncation blindly drops tokens and can lose critical facts the task still depends on.
Common exam traps
- Confusing compaction (summarize to reclaim budget) with simply truncating (dropping tokens blindly, which can lose critical facts). They look similar in effect (context shrinks) but differ sharply in whether meaning is preserved.
Key Takeaways
- Prune large tool payloads down to what later steps actually need; don't carry raw dumps in history
- Compaction summarizes older turns into a compact recap, reclaiming budget while preserving the thread
- Compaction is not the same as truncation -- truncation blindly drops tokens and can lose critical facts
- Compaction is the mechanism that lets long agent sessions avoid drift
Glossary Terms
The practice of actively reducing a conversation's token footprint so it fits within the model's context window without silent truncation. Encompasses multiple strategies — rolling window eviction, progressive summarization, external storage with retrieval, and prompt caching — each with different loss profiles and complexity trade-offs. Understanding this menu of options, and knowing what must never be compressed, is a core Domain 5 skill.
A context management technique that retains only the N most recent conversation turns, evicting older turns as new ones arrive. Simple to implement with zero summarization overhead. Best deployed as a rolling-window+summary-header hybrid to prevent silent loss of early constraints or decisions. One specific technique under the broader umbrella of [context compression](/glossary/context-compression).
A context management approach that condenses older conversation turns or completed task phases into compact summaries, preserving essential conclusions while freeing token budget. Inherently lossy — never summarize active tool results, in-flight constraints, or partially completed tasks. One specific technique under the broader umbrella of [context compression](/glossary/context-compression).
Related Concepts
Context Rot and Context Drift
Context rot is attention degradation from irrelevant/stale content filling the window, not from running out of room
Context Isolation via Subagents and Just-in-Time Retrieval
Context isolation delegates heavy subtasks to a subagent with its own window, keeping the main context clean