pub struct SummaryMemory { /* private fields */ }Expand description
LLM-backed memory: when message count exceeds threshold, summarize the
oldest threshold/2 messages into a single system message (via the
supplied Client) and drop the originals.
Summarization is lazy — it runs in seed() (called by the agent
before each turn). That keeps write() synchronous, which is what
the Memory trait requires.
Implementations§
Source§impl SummaryMemory
impl SummaryMemory
Sourcepub fn new(client: Client, threshold: usize) -> Self
pub fn new(client: Client, threshold: usize) -> Self
Build with the LLM client used to summarize, and the message count at which compression kicks in.
Sourcepub fn with_system(self, prompt: impl Into<String>) -> Self
pub fn with_system(self, prompt: impl Into<String>) -> Self
Pin a system message at the head of the seed.
Sourcepub fn with_prompt(self, p: impl Into<String>) -> Self
pub fn with_prompt(self, p: impl Into<String>) -> Self
Override the summarization prompt.
Source§impl SummaryMemory
impl SummaryMemory
Sourcepub fn needs_compact(&self) -> bool
pub fn needs_compact(&self) -> bool
True when the buffer has grown past the configured threshold and a
compact() call would do work.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SummaryMemory
impl !RefUnwindSafe for SummaryMemory
impl Send for SummaryMemory
impl Sync for SummaryMemory
impl Unpin for SummaryMemory
impl UnsafeUnpin for SummaryMemory
impl !UnwindSafe for SummaryMemory
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