Expand description
Context management — output truncation and history window management.
Structs§
- Context
Manager - Manages the context window, truncating history when approaching token limits.
- Truncation
Result - Result of context truncation, used for async compression.
Functions§
- estimate_
messages_ tokens - Estimate tokens for a list of messages.
- estimate_
tokens - Estimate token count for a string. Uses a simple heuristic: ~4 chars per English token, ~2 chars per Chinese token. For mixed content, we use ~3 chars per token as a rough estimate.
- truncate_
output - Truncate tool output based on line count and byte limits.