pub struct KeepRecentStrategy { /* private fields */ }Expand description
Strategy that keeps only the N most recent removable items and drops
the rest.
Items whose ItemKind is in the preserve_kinds set are always
retained regardless of their position. This lets you protect system
prompts and context items while trimming older conversation turns.
§Example
use agentkit_compaction::KeepRecentStrategy;
use agentkit_core::ItemKind;
let strategy = KeepRecentStrategy::new(16)
.preserve_kind(ItemKind::System)
.preserve_kind(ItemKind::Context);Implementations§
Trait Implementations§
Source§impl Clone for KeepRecentStrategy
impl Clone for KeepRecentStrategy
Source§fn clone(&self) -> KeepRecentStrategy
fn clone(&self) -> KeepRecentStrategy
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 moreSource§impl CompactionStrategy for KeepRecentStrategy
impl CompactionStrategy for KeepRecentStrategy
Source§fn apply<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: CompactionRequest,
_ctx: &'life1 mut CompactionContext<'life2>,
) -> Pin<Box<dyn Future<Output = Result<CompactionResult, CompactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn apply<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: CompactionRequest,
_ctx: &'life1 mut CompactionContext<'life2>,
) -> Pin<Box<dyn Future<Output = Result<CompactionResult, CompactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Apply this strategy to the transcript in
request. Read moreSource§impl Debug for KeepRecentStrategy
impl Debug for KeepRecentStrategy
Source§impl<'de> Deserialize<'de> for KeepRecentStrategy
impl<'de> Deserialize<'de> for KeepRecentStrategy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for KeepRecentStrategy
impl PartialEq for KeepRecentStrategy
Source§impl Serialize for KeepRecentStrategy
impl Serialize for KeepRecentStrategy
impl Eq for KeepRecentStrategy
impl StructuralPartialEq for KeepRecentStrategy
Auto Trait Implementations§
impl Freeze for KeepRecentStrategy
impl RefUnwindSafe for KeepRecentStrategy
impl Send for KeepRecentStrategy
impl Sync for KeepRecentStrategy
impl Unpin for KeepRecentStrategy
impl UnsafeUnpin for KeepRecentStrategy
impl UnwindSafe for KeepRecentStrategy
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