Summarization uses a model to condense interaction history, tool outputs, or completed phases into a shorter representation for an agent’s context window. A useful summary preserves task intent, decisions, artifacts, current state, open issues, and next steps while replacing less useful detail. section 7.4.2 section 5.2.2
Memory compression can maintain summaries in several forms:
- Rolling summaries update after every few turns. section 5.2.2
- Hierarchical summaries keep detailed recent summaries alongside high-level historical digests. section 5.2.2
- Hybrid summaries combine prose with structured key-value attributes. section 5.2.2
For long sessions, anchored iterative summarization summarizes only the newly removed span and merges it into the existing summary. This can reduce drift compared with regenerating the whole summary at each compression event. Compression is also useful after a token-heavy search, after a research phase, or before an agent handoff. section 7.4.2
Summarization rewrites content; trimming removes it without rewriting. Observation masking replaces a bulky tool result in the active prompt with a concise summary and a storage pointer, so the full result can be recovered. Recent observations, unresolved errors, and evidence needed for active reasoning should remain unmasked. section 7.4.2
Compaction in a coding agent
When a conversation approaches its context limit, a harness can invoke a secondary model pass to summarize modified files, command outcomes, and architectural decisions. It discards lengthy command logs while retaining the high-level task goals. section 5.2.2
Successive summaries can introduce distortions that compound as earlier summaries become input to later ones. Treat summaries as editable artifacts, validate them against user actions, and periodically re-anchor the model with recent verbatim context. section 5.2.2
















