pub struct SlidingWindowTransformer { /* private fields */ }Expand description
Built-in sliding window context transformer with compaction reporting.
Wraps the same logic as sliding_window but
captures compaction metrics for reporting.
Accepts an optional TokenCounter for pluggable token estimation.
When none is provided, the default chars / 4 heuristic is used.
Implementations§
Source§impl SlidingWindowTransformer
impl SlidingWindowTransformer
Sourcepub fn new(normal_budget: usize, overflow_budget: usize, anchor: usize) -> Self
pub fn new(normal_budget: usize, overflow_budget: usize, anchor: usize) -> Self
Create a new sliding window transformer.
§Arguments
normal_budget- Token budget under normal operation.overflow_budget- Smaller token budget used when overflow is signaled.anchor- Number of messages at the start to always preserve.
pub fn with_token_counter(self, counter: Arc<dyn TokenCounter>) -> Self
Sourcepub const fn with_cached_prefix_len(self, len: usize) -> Self
pub const fn with_cached_prefix_len(self, len: usize) -> Self
Set the cached prefix length to protect from compaction.
When caching is active, the effective anchor is max(anchor, cached_prefix_len).
Sourcepub const fn set_cached_prefix_len(&mut self, len: usize)
pub const fn set_cached_prefix_len(&mut self, len: usize)
Update the cached prefix length (for runtime updates from the turn pipeline).
Trait Implementations§
Source§impl ContextTransformer for SlidingWindowTransformer
impl ContextTransformer for SlidingWindowTransformer
Source§fn transform(
&self,
messages: &mut Vec<AgentMessage>,
overflow: bool,
) -> Option<CompactionReport>
fn transform( &self, messages: &mut Vec<AgentMessage>, overflow: bool, ) -> Option<CompactionReport>
Transform the context messages in-place. Read more
Auto Trait Implementations§
impl Freeze for SlidingWindowTransformer
impl !RefUnwindSafe for SlidingWindowTransformer
impl Send for SlidingWindowTransformer
impl Sync for SlidingWindowTransformer
impl Unpin for SlidingWindowTransformer
impl UnsafeUnpin for SlidingWindowTransformer
impl !UnwindSafe for SlidingWindowTransformer
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