Quick Start
How It Works
Analyzer Strategy Decision:| Strategy | Uses LLM? | When to use |
|---|---|---|
hybrid (default) | LLM with rule-based fallback | Best balance — recommended |
rule_based | No | Predictable / no extra LLM cost |
llm_only | Yes (required) | Highest fidelity, requires llm_analyze_fn |
ConversationContext Shape
| Field | Type | Description |
|---|---|---|
main_topic | str | Primary conversation topic |
current_goal | str | User’s current objective |
progress_summary | str | Progress made towards goal |
key_decisions | List[str] | Important decisions made |
important_facts | List[str] | Critical factual information |
action_items | List[str] | Next steps or todo items |
user_preferences | List[str] | Expressed user preferences |
tool_results_summary | List[str] | Summaries of tool outputs |
conversation_tone | str | Tone: casual, professional, technical |
original_message_count | int | Messages before compaction |
compacted_message_count | int | Messages after compaction |
compaction_timestamp | float | When compaction occurred |
.to_summary_message() example output:
ManagerConfig Fields
| Field | Type | Default | Description |
|---|---|---|---|
conversation_compaction | bool | False | Enable intelligent conversation compaction |
conversation_analyzer_strategy | str | "hybrid" | "hybrid", "rule_based", or "llm_only" |
conversation_min_compaction_ratio | float | 0.3 | Skip compaction if savings below this ratio |
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

