Overview
Create a smart context management algorithm that optimizes token usage and maintains context within model token limits.
Requirements
- Create
TokenAwareAlgorithm class extending BaseAlgorithm
- Features:
- Real-time token counting
- Dynamic context window sizing
- Priority-based message retention
- Token budget management
- Support for different tokenizers (tiktoken, sentencepiece)
Technical Details
- Token counting:
- Message content
- System prompts
- Function calls
- Response tokens
- Smart truncation strategies:
- Preserve recent messages
- Keep important context
- Remove redundant information
- Configurable buffer for response tokens
Acceptance Criteria
Overview
Create a smart context management algorithm that optimizes token usage and maintains context within model token limits.
Requirements
TokenAwareAlgorithmclass extendingBaseAlgorithmTechnical Details
Acceptance Criteria