How It Works
Local models — window comes from the server
Since PR #4924, when PraisonAI has already probed a locally-served model it uses the window the server reported, not the litellm default.
Hosted providers are untouched:
gpt-4o still resolves through litellm.
The probed window is a process-local, no-I/O cache — populated when the local layer first records what /api/show reported, then read on every budgeting call without touching the network.
Quick Start
1
Install Package
Install PraisonAI Agents:
2
Import Context Manager
Import context management utilities:
3
Create Example
Create
context_management.py:4
Run Example
Execute the context management example:
Core Features
Token Counting
Context Optimization
Smart Truncation
Advanced Context Management
Dynamic Context Allocation
Context Windowing
Hierarchical Context Management
Context Strategies
Summarization Strategy
Chunking Strategy
Priority-Based Selection
Model-Specific Management
Monitoring and Analytics
Best Practices
Reserve Tokens
Reserve Tokens
Always reserve tokens for model responses:
Context Prioritization
Context Prioritization
Prioritize context elements:
Optimization Strategies
Optimization Strategies
Choose appropriate optimization:
Troubleshooting
Token Limit Exceeded
If hitting token limits:
- Enable aggressive optimization
- Reduce context items
- Use summarization
- Switch to larger context model
Context Loss
If losing important context:
- Adjust priority weights
- Increase overlap in chunking
- Use hierarchical management
- Enable context compression
Next Steps
Model Capabilities
Learn about model-specific context limits
Memory Systems
Explore long-term context preservation
Tool Output Store
Recover full tool outputs after truncation
Effective context window management is crucial for handling large documents, maintaining conversation history, and optimizing token usage. The system automatically adapts to different models and use cases while preserving the most important information.
Related
Control what context is assembled and passed into each agent turn.
Look up per-model context limits before tuning window management.

