pub fn compact_messages(
messages: Vec<AgentMessage>,
config: &ContextConfig,
) -> Vec<AgentMessage>Expand description
Compact messages to fit within the token budget using tiered strategy.
- Level 1: Truncate tool outputs (keep head + tail)
- Level 2: Summarize old turns (replace details with one-liner)
- Level 3: Drop old messages (keep first + recent only)
Each level is tried in order. Returns as soon as messages fit.