pub type CompactionHook = Arc<dyn Fn(CompactedContext) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> + Send + Sync>;Expand description
Async hook invoked after context compaction completes.
Receives the CompactedContext and returns a Result<()> future.
The future is awaited within the agent loop, so async operations
(memory storage, logging, etc.) are safe here.
§Example
ⓘ
let config = AgentLoopConfig {
on_compaction: Some(Arc::new(|ctx: CompactedContext| {
let summary = ctx.summary.clone();
Box::pin(async move {
memory_store.save(summary).await
})
})),
..Default::default()
};Aliased Type§
pub struct CompactionHook { /* private fields */ }