pub struct AgentMemory { /* private fields */ }Expand description
Long-term memory for one user and one session: facts about the user and a session summary, kept in a SQLite file. The agent gets the five memory tools, bound to this user and session, and by default the facts and summary are prepended to every run’s input.
Implementations§
Source§impl AgentMemory
impl AgentMemory
Sourcepub fn new(user: impl Into<String>, session: impl Into<String>) -> Self
pub fn new(user: impl Into<String>, session: impl Into<String>) -> Self
Starts memory bound to user, whose facts the tools touch, and
session, whose summary they touch. Both are chosen by the host,
never by the model; 1 to 256 bytes each, checked at build.
Sourcepub fn sqlite(self, path: impl AsRef<Path>) -> Self
pub fn sqlite(self, path: impl AsRef<Path>) -> Self
Sets the SQLite file facts and summaries live in. Required in 0.2
unless the agent also has .knowledge(..), whose store is used.
Returns the memory settings.
Sourcepub fn preamble(self, on: bool) -> Self
pub fn preamble(self, on: bool) -> Self
Turns the preamble of facts and summary before each run on or off.
Default true.
Returns the memory settings.
Sourcepub fn fact_caps(
self,
max_fact_bytes: usize,
max_facts: usize,
max_log: usize,
) -> Self
pub fn fact_caps( self, max_fact_bytes: usize, max_facts: usize, max_log: usize, ) -> Self
Caps one fact’s bytes, the facts per user and the fact log length.
Defaults 1024, 200 and 1000; zero is refused at build.
Returns the memory settings.
Sourcepub fn max_summary_bytes(self, bytes: usize) -> Self
pub fn max_summary_bytes(self, bytes: usize) -> Self
Caps the session summary in bytes.
Default 4096; zero is refused at build.
Returns the memory settings.
Sourcepub fn preamble_budget_tokens(self, tokens: usize) -> Self
pub fn preamble_budget_tokens(self, tokens: usize) -> Self
Caps the preamble in estimated tokens; facts that do not fit are
left out. Default 800; zero is refused at build.
Returns the memory settings.