Skip to main content

compact_history

Function compact_history 

Source
async fn compact_history(history: &mut Vec<Message>, vlm: &VlmClient)
Expand description

Claude-Code-style rolling compaction. When the running history grows past HISTORY_COMPACT_TRIGGER_CHARS, summarize everything except the most recent HISTORY_KEEP_RECENT messages into a single summary note (preserving goal, decisions, observations, and current state) and keep the recent turns verbatim. This shrinks the per-round prompt for the rest of the turn instead of re-shipping the full transcript every round.

Best-effort: any VLM error leaves history untouched (the MAX_HISTORY trim still bounds it). Self-limiting: after compaction the total drops below the trigger, so it won’t fire again until history regrows.