pub trait CoreMemory: Send + Sync {
// Required methods
fn blocks(
&self,
) -> impl Future<Output = Result<Vec<CoreMemoryBlock>>> + Send;
fn put_block(
&self,
block: CoreMemoryBlock,
) -> impl Future<Output = Result<()>> + Send;
fn append_block(
&self,
label: &str,
text: &str,
) -> impl Future<Output = Result<()>> + Send;
fn remove_block(
&self,
label: &str,
) -> impl Future<Output = Result<bool>> + Send;
// Provided methods
fn get_block(
&self,
label: &str,
) -> impl Future<Output = Result<Option<CoreMemoryBlock>>> + Send { ... }
fn render(&self) -> impl Future<Output = Result<String>> + Send { ... }
}Expand description
Trait for always-in-context core memory backends.
Core memory is distinct from Memory: it is not
a chronological log, it is a small set of labeled blocks that are
rendered as a whole and re-injected into the system prompt every turn.
The agent itself (via a tool) or the host application can read and edit
blocks between turns.
Required Methods§
Sourcefn blocks(&self) -> impl Future<Output = Result<Vec<CoreMemoryBlock>>> + Send
fn blocks(&self) -> impl Future<Output = Result<Vec<CoreMemoryBlock>>> + Send
Returns all blocks currently stored.
Sourcefn put_block(
&self,
block: CoreMemoryBlock,
) -> impl Future<Output = Result<()>> + Send
fn put_block( &self, block: CoreMemoryBlock, ) -> impl Future<Output = Result<()>> + Send
Creates a block (if block.label is new) or overwrites the value and
limit of an existing one. Fails if block.value exceeds block.limit.
Provided Methods§
Sourcefn get_block(
&self,
label: &str,
) -> impl Future<Output = Result<Option<CoreMemoryBlock>>> + Send
fn get_block( &self, label: &str, ) -> impl Future<Output = Result<Option<CoreMemoryBlock>>> + Send
Returns a single block by label, if it exists.
Sourcefn render(&self) -> impl Future<Output = Result<String>> + Send
fn render(&self) -> impl Future<Output = Result<String>> + Send
Renders all blocks into a single string suitable for splicing into a
system prompt. Default rendering is "## {label}\n{value}" per
block, joined by blank lines, in the order returned by blocks.
See render_blocks for the header-injection protection applied to
value before formatting.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".