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_
messages_ tokens_ with_ margin - Estimate tokens for messages, applying the configured safety margin.
- estimate_
tokens - Estimate token count for a string.
- format_
removed_ messages_ as_ transcript - Format removed messages into a compact transcript for summary generation. Extracts user messages, assistant text, and tool call names only. Truncates each message to keep the transcript concise.
- truncate_
output - Truncate tool output based on line count and byte limits.