pub struct ModelBackedCompactor {
pub model: Arc<dyn Model>,
pub tokens_per_char: f32,
pub keep_recent: usize,
pub summary_max_tokens: u32,
}Expand description
Compactor that calls an LLM for the inferential stages and falls back to
DefaultCompactor’s structural strategies for the computational ones.
Typical wiring:
ⓘ
let cheap = OpenAiCompat::with_key(providers::DEEPSEEK, "deepseek-v4-flash", key);
let compactor = ModelBackedCompactor::new(Arc::new(cheap));
let loop_ = AgentLoop::new(main_model).with_compactor(Arc::new(compactor));Fields§
§model: Arc<dyn Model>§tokens_per_char: f32§keep_recent: usizeKeep the most recent N turns intact during semantic compaction.
summary_max_tokens: u32Hard cap on the summary length the model is asked to produce.
Implementations§
Trait Implementations§
Source§impl Compactor for ModelBackedCompactor
impl Compactor for ModelBackedCompactor
fn budget(&self, ctx: &Context) -> Budget
fn compact<'life0, 'life1, 'async_trait>(
&'life0 self,
stage: CompactionStage,
ctx: &'life1 mut Context,
) -> Pin<Box<dyn Future<Output = Result<(), CompactError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for ModelBackedCompactor
impl !UnwindSafe for ModelBackedCompactor
impl Freeze for ModelBackedCompactor
impl Send for ModelBackedCompactor
impl Sync for ModelBackedCompactor
impl Unpin for ModelBackedCompactor
impl UnsafeUnpin for ModelBackedCompactor
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