pub struct RuleBasedCompressor { /* private fields */ }Expand description
Scores messages by importance and removes lowest-scored first.
Scoring table (configurable):
- System messages: never removed (score ∞)
- Last
recent_countmessages: 0.9 - Tool-result messages: 0.7
- Older user/assistant messages: 0.3
§Example
use traitclaw_core::context_managers::RuleBasedCompressor;
let compressor = RuleBasedCompressor::new(0.85, 3);Implementations§
Trait Implementations§
Source§impl ContextManager for RuleBasedCompressor
impl ContextManager for RuleBasedCompressor
Source§fn prepare<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 mut Vec<Message>,
context_window: usize,
state: &'life2 mut AgentState,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn prepare<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 mut Vec<Message>,
context_window: usize,
state: &'life2 mut AgentState,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Prepare the message list by pruning or compressing if necessary. Read more
Auto Trait Implementations§
impl Freeze for RuleBasedCompressor
impl RefUnwindSafe for RuleBasedCompressor
impl Send for RuleBasedCompressor
impl Sync for RuleBasedCompressor
impl Unpin for RuleBasedCompressor
impl UnsafeUnpin for RuleBasedCompressor
impl UnwindSafe for RuleBasedCompressor
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