Skip to content

memory

Long-term memory trait ports.

Defines the interface for cross-conversation semantic memory backends (e.g. Qdrant + embeddings). This module contains only trait definitions and types — implementations live in agent_memory_store.

WASM-compatible: no async runtime dependencies.

type MemoryFuture = Pin<Box<dyn Future + Send>>;

Boxed future type for native (requires Send).

Trait port for long-term memory backends.

Implementations handle embedding, storage, and semantic retrieval. The trait is object-safe and WASM-compatible.

  • agent_memory_store::QdrantMemoryStore — Qdrant + embedding_provider_lib
  • In-memory store for testing

Required / Provided Methods

fn store(&self, entry: MemoryEntry) -> MemoryFuture<()>

Store a memory entry (embedding + indexing happens internally).

fn recall(&self, query: &str, top_k: usize, filters: MemoryFilters) -> MemoryFuture<Vec<MemoryEntry>>

Recall relevant memories by semantic similarity to a query.

Returns up to top_k entries sorted by relevance (highest first).

fn forget(&self, filters: MemoryFilters) -> MemoryFuture<u64>

Delete memories matching the given filters.

Returns the number of entries deleted.

A single memory entry stored in the long-term memory backend.

Fields

FieldTypeDescription
idStringUnique ID for this memory entry.
agent_idStringAgent that created this memory.
user_idOption&lt;String&gt;User this memory belongs to (for multi-tenant isolation).
conversation_idOption&lt;String&gt;Conversation this memory was extracted from.
contentStringThe text content to embed and store.
memory_typeMemoryTypeClassification of this memory.
timestampu64Unix timestamp (seconds) when this memory was created.
scoref32Relevance score (set during retrieval, 0.0 to 1.0).
metadataHashMap&lt;String, serde_json::Value&gt;Arbitrary metadata (e.g. source turn number, tags).

Filters for memory retrieval.

Fields

FieldTypeDescription
agent_idOption&lt;String&gt;Filter by agent ID.
user_idOption&lt;String&gt;Filter by user ID.
conversation_idOption&lt;String&gt;Filter by conversation ID.
memory_typesVec&lt;MemoryType&gt;Filter by memory type(s).
after_timestampOption&lt;u64&gt;Only return memories newer than this timestamp (seconds).

No-op memory backend (used when long-term memory is disabled).

Type of memory entry — helps with filtering and relevance scoring.

Variants

VariantDescription
SummarySummarized conversation segment.
FactExtracted factual statement (e.g. “User prefers dark mode”).
InstructionUser instruction or preference.
ToolResultCompressed tool result worth remembering.
Custom(String)Arbitrary user-defined type.