Context Optimizer
The Context Optimizer provides multiple strategies for reducing context size when approaching model limits, preventing overflow errors and reducing costs.Agent-Centric Quick Start
Optimization Strategies
Low-Level API
Strategy Reference
Truncate
Removes oldest messages first, preserving system prompt and recent context.Sliding Window
Keeps the N most recent messages within a token window.Prune Tools
Truncates old tool outputs while preserving recent ones.Summarize
Uses LLM to create a summary of older conversation.Non-Destructive
Tags messages for exclusion without deleting them (enables undo).Smart (Recommended)
Combines all strategies intelligently based on content analysis.- Prune old tool outputs
- Apply sliding window
- Summarize if still over limit
Factory Function
Optimization Result
Tool Call Preservation
The optimizer preserves tool_call/tool_result pairs to maintain API validity:CLI Usage
Configuration
Next Steps
- Context Monitor - Watch optimization in action
- Context Budgeter - Set up budgets

