Skip to main content

CompactionConfig

Struct CompactionConfig 

Source
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: MetadataMap

Metadata forwarded to every strategy invocation.

Implementations§

Source§

impl CompactionConfig

Source

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 (or CompactionPipeline) to execute.
Source

pub fn with_backend(self, backend: impl CompactionBackend + 'static) -> Self

Attach a CompactionBackend for strategies that require summarisation (e.g. SummarizeOlderStrategy).

Source

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

Source§

fn clone(&self) -> CompactionConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.