Expand description
Session memory compaction.
Uses pre-extracted session memory as the summary instead of making an API call. Keeps recent messages above minimum thresholds and preserves API invariants.
Structs§
- Session
Memory Compact Config - Configuration for session memory compaction thresholds
- Session
Memory Compact Result - Result from session memory compaction
Functions§
- adjust_
index_ to_ preserve_ api_ invariants - Adjust the start index to ensure we don’t split tool_use/tool_result pairs or thinking blocks that share the same message.id with kept assistant messages.
- calculate_
messages_ to_ keep_ index - Calculate the starting index for messages to keep after compaction.
- get_
session_ memory_ compact_ config - Get the current session memory compact configuration
- has_
text_ blocks - Check if a message contains text blocks
- is_
compact_ boundary_ message - Check if a message is a compact boundary message
- should_
use_ session_ memory_ compaction - Check if session memory compaction should be used
- try_
session_ memory_ compaction - Try to use session memory for compaction instead of traditional compaction. Returns None if session memory compaction cannot be used.