Quick Start
1
Enable on Agent via ManagerConfig
2
Low-Level Class
3
Direct API for full control
How It Works
Analyzer Strategy Decision:ConversationContext Shape
The protocol classes were renamed in PR #1899 to
ConversationAnalyzerProtocol and ConversationCompactorProtocol. The old unsuffixed names (ConversationAnalyzer, ConversationCompactor) remain as deprecated backward-compatible aliases..to_summary_message() example output:
ManagerConfig Fields
OptimizerStrategy.CONVERSATION
Usestrategy="conversation" for:
- Long conversations with topic evolution β preserves narrative flow better than basic summarization
- Multi-hour planning sessions β tracks decisions and action items across topic changes
- Iterative development β maintains context of completed work and next steps
strategy="conversation"β Structured summaries with topic/goal trackingstrategy="smart"β Adaptive optimization (pruning, sliding window, etc.)strategy="summarize"β Simple LLM summarization without structure
Common Patterns
Multi-hour planning sessions:Best Practices
Keep min_compaction_ratio >= 0.3
Keep min_compaction_ratio >= 0.3
Setting the minimum compaction ratio to at least 30% ensures summaries provide meaningful token savings. Lower ratios may waste computational resources on minimal gains.
Use hybrid unless you have strong reasons
Use hybrid unless you have strong reasons
The
hybrid strategy provides the best balance of quality and reliability. Use rule_based only when LLM costs are prohibitive, and llm_only only when maximum fidelity is critical.preserve_recent=5 is a good default
preserve_recent=5 is a good default
Preserving the last 5 messages maintains immediate context while allowing effective compaction. Increase this for tool-heavy conversations where recent outputs are critical.
Inspect key_decisions after compaction
Inspect key_decisions after compaction
Always verify that critical decisions were captured correctly by checking
context.key_decisions. This helps catch cases where important information might be lost.Related
LLM Context Compression
LLM-driven compression with session lineage and head/tail protection
Context Optimizer
Overview of all optimization strategies including conversation compaction
Context Strategies
Choosing the right optimization approach for your use case
Context Compaction
Basic compaction strategies and when to use intelligent compaction

