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.
Enums§
- Truncation
Action - Type of truncation action, determines how the caller should handle the result.
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.
- get_
merge_ level - Get the merge level (number of times this segment has been merged). 0 = fresh segment, 1 = merged once, etc.
- is_
summary_ segment - Check whether a message is a summary segment (any merge level, including legacy notice).
- truncate_
output - Truncate tool output based on line count and byte limits.