Skip to main content

MemoryContext

Trait MemoryContext 

Source
pub trait MemoryContext: SessionContext {
    // Required methods
    fn active_window(&self) -> &[Message];
    fn demote(&self, messages: Vec<Message>) -> Result<(), String>;
    fn compact(&self, messages: Vec<Message>) -> Result<String, String>;
}
Expand description

Context for memory operations (demotion, compaction).

Extends SessionContext with access to the active window and the ability to demote or compact messages.

Required Methods§

Source

fn active_window(&self) -> &[Message]

Returns the current active window (recent messages in context).

Source

fn demote(&self, messages: Vec<Message>) -> Result<(), String>

Demotes messages from the active window to long-term storage.

Returns an error if the demotion hook is not configured or the storage backend is unavailable.

Source

fn compact(&self, messages: Vec<Message>) -> Result<String, String>

Compacts messages into a summary and injects it back into the active window.

Returns the generated summary text.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§