Skip to main content

compact_session_loops

Function compact_session_loops 

Source
pub async fn compact_session_loops(
    session: &mut Session,
    current_loop_id: &str,
    strategy: &dyn BlockCompactionStrategy,
    config: &CompactionConfig,
    max_context_tokens: usize,
    counter: Option<&Arc<dyn TokenCounter>>,
)
Expand description

Create CompactionBlocks for the current loop and earlier loops within scope. Mutates the session in place.

When counter is None, uses HeuristicTokenCounter (chars/4) as the default. The caller is responsible for persisting the session to disk afterward.

0.9.0 breaking change: this function is now async fn so it can drive the async BlockCompactionStrategy::compact method. Callers must .await the call; synchronous callers can use tokio::runtime::Handle::current() .block_on(...) if no awaiter is available (uncommon — session compaction is typically invoked from within an agent loop, which is already async).