Skip to main content

praisonaiagents.compaction

Core SDK Auto Context Compaction Module for PraisonAI Agents. Provides automatic context management for long conversations:
  • Message summarization
  • Context window management
  • Token counting and limits
  • Intelligent message pruning
Zero Performance Impact:
  • All imports are lazy loaded via getattr
  • Compaction only runs when needed
  • No overhead when context is within limits
Usage: from praisonaiagents.compaction import ContextCompactor, CompactionConfig

Create a compactor

compactor = ContextCompactor( max_tokens=8000, strategy=“summarize” )

Compact messages when needed

compacted = compactor.compact(messages)

Overview

This module provides components for compaction.