pub struct CompactionPipeline { /* private fields */ }Expand description
An ordered sequence of CompactionStrategy steps executed one after
another.
Each strategy receives the transcript produced by the previous one,
creating a pipeline effect. The pipeline itself implements
CompactionStrategy, so it can be nested or used anywhere a single
strategy is expected.
The pipeline checks the CompactionContext::cancellation token between
steps and returns CompactionError::Cancelled early if cancellation is
signalled.
§Example
use agentkit_compaction::{
CompactionPipeline, DropFailedToolResultsStrategy,
DropReasoningStrategy, KeepRecentStrategy,
};
use agentkit_core::ItemKind;
let pipeline = CompactionPipeline::new()
.with_strategy(DropReasoningStrategy::new())
.with_strategy(DropFailedToolResultsStrategy::new())
.with_strategy(
KeepRecentStrategy::new(24)
.preserve_kind(ItemKind::System)
.preserve_kind(ItemKind::Context),
);Implementations§
Source§impl CompactionPipeline
impl CompactionPipeline
Sourcepub fn with_strategy(self, strategy: impl CompactionStrategy + 'static) -> Self
pub fn with_strategy(self, strategy: impl CompactionStrategy + 'static) -> Self
Append a strategy to the end of the pipeline.
Strategies run in the order they are added.
Trait Implementations§
Source§impl Clone for CompactionPipeline
impl Clone for CompactionPipeline
Source§fn clone(&self) -> CompactionPipeline
fn clone(&self) -> CompactionPipeline
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 CompactionPipeline
impl CompactionStrategy for CompactionPipeline
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 Default for CompactionPipeline
impl Default for CompactionPipeline
Source§fn default() -> CompactionPipeline
fn default() -> CompactionPipeline
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CompactionPipeline
impl !RefUnwindSafe for CompactionPipeline
impl Send for CompactionPipeline
impl Sync for CompactionPipeline
impl Unpin for CompactionPipeline
impl UnsafeUnpin for CompactionPipeline
impl !UnwindSafe for CompactionPipeline
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