Skip to main content

execute_manual_compaction

Function execute_manual_compaction 

Source
pub fn execute_manual_compaction<F>(
    session: &mut SessionManager,
    keep_recent_groups: usize,
    generate_summary: F,
) -> Result<Option<CompactionResult>>
where F: FnOnce(&str) -> Option<String>,
Expand description

Execute a manual compaction on the current branch of a session.

This is the main entry point for /compact. It:

  1. Prepares the history via the safe deterministic pipeline.
  2. Generates a structured summary of the older prefix.
  3. Persists a SessionEntry::Compaction that partitions the branch.

The generate_summary closure receives the serialized summarization prompt and returns the LLM-generated summary text. This keeps the compaction module independent of specific LLM wiring.

Returns None if there is not enough history to compact.