pub struct CompactionConfig {
pub trigger: Arc<dyn CompactionTrigger>,
pub strategy: Arc<dyn CompactionStrategy>,
pub backend: Option<Arc<dyn CompactionBackend>>,
pub metadata: MetadataMap,
}Expand description
Top-level configuration that bundles a trigger, strategy, and optional
backend into a single value you can hand to agentkit-loop.
§Example
use agentkit_compaction::{
CompactionConfig, CompactionPipeline, DropReasoningStrategy,
ItemCountTrigger, KeepRecentStrategy,
};
use agentkit_core::ItemKind;
let config = CompactionConfig::new(
ItemCountTrigger::new(32),
CompactionPipeline::new()
.with_strategy(DropReasoningStrategy::new())
.with_strategy(
KeepRecentStrategy::new(24)
.preserve_kind(ItemKind::System)
.preserve_kind(ItemKind::Context),
),
);Fields§
§trigger: Arc<dyn CompactionTrigger>The trigger that decides when compaction should run.
strategy: Arc<dyn CompactionStrategy>The strategy (or pipeline of strategies) to execute.
backend: Option<Arc<dyn CompactionBackend>>An optional backend for strategies that need summarisation.
metadata: MetadataMapMetadata forwarded to every strategy invocation.
Implementations§
Source§impl CompactionConfig
impl CompactionConfig
Sourcepub fn new(
trigger: impl CompactionTrigger + 'static,
strategy: impl CompactionStrategy + 'static,
) -> Self
pub fn new( trigger: impl CompactionTrigger + 'static, strategy: impl CompactionStrategy + 'static, ) -> Self
Create a new configuration with the given trigger and strategy.
The backend defaults to None. Use with_backend
to attach one when your pipeline includes SummarizeOlderStrategy.
§Arguments
trigger- Decides when compaction should fire.strategy- The strategy (orCompactionPipeline) to execute.
Sourcepub fn with_backend(self, backend: impl CompactionBackend + 'static) -> Self
pub fn with_backend(self, backend: impl CompactionBackend + 'static) -> Self
Attach a CompactionBackend for strategies that require
summarisation (e.g. SummarizeOlderStrategy).
Sourcepub fn with_metadata(self, metadata: MetadataMap) -> Self
pub fn with_metadata(self, metadata: MetadataMap) -> Self
Set metadata that will be forwarded to every strategy invocation.
Trait Implementations§
Source§impl Clone for CompactionConfig
impl Clone for CompactionConfig
Source§fn clone(&self) -> CompactionConfig
fn clone(&self) -> CompactionConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CompactionConfig
impl !RefUnwindSafe for CompactionConfig
impl Send for CompactionConfig
impl Sync for CompactionConfig
impl Unpin for CompactionConfig
impl UnsafeUnpin for CompactionConfig
impl !UnwindSafe for CompactionConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more