Memory
Long-term memory is optional, and the rest of the SDK never depends on it. It plugs into an agent through a public trait, MemorySystem, so you can swap the whole system, or just the parts under it.
Plug in a memory system
A MemorySystem returns, for each turn, the hooks and tools it wants on that turn (recall injection, a remember tool, run-end learning), plus optional guidance text for the model. Hand it to the preset with a MemoryTurn that says which memory the turn uses and whether it may read and write:
use aidaemon_sdk::policies::{MemorySystem, MemoryTurn};
let turn = MemoryTurn {
session_id: "cli:me".into(),
scope: "owner".into(), // the memory this turn reads and writes
read: true,
write: true,
explicit_writes_only: true, // only the remember tool writes
learning: Default::default(),
};
let agent = aidaemon_sdk::preset("assistant")
.provider_from_env()
.memory(memory_system, turn) // Arc<dyn MemorySystem>
.build()
.await?;The memory_swap example runs one agent on two systems: aidaemon-memory, and a ten-line notebook written in the example. A vector database or a hosted memory service plugs in the same way.
The aidaemon-memory system: ScopedMemory
The aidaemon-memory crate (SDK feature memory) is the facts-and-episodes memory with hybrid recall. ScopedMemory is that crate packaged as a whole MemorySystem:
use aidaemon_sdk::memory::{HashEmbedder, InMemoryMemoryStore, Memory, ScopedMemory};
use std::sync::Arc;
let builder = Memory::builder(
Arc::new(InMemoryMemoryStore::new()),
Arc::new(HashEmbedder::default()),
);
let system = ScopedMemory::new(builder);It reads and writes the scope each session's latest turn was given, so your app can map many sessions to one memory (the owner's direct messages) and keep others apart (each group conversation). The host decides who may see what; the memory system only decides how to remember and recall within that scope. If you know how the AIDaemon daemon remembers facts and episodes, this is the same model, available as a building block rather than as the daemon's built-in wiring.
Swap the parts instead
Under Memory, each part is a trait object and replaceable:
MemoryStore— where facts and episodes live. SQLite is included; implement the trait for pgvector, Qdrant, a document database, and so on. Only row storage is required; other methods have safe defaults.Embedder— turns text into vectors (model_id,dimensions,embed).HashEmbedderworks offline; thefastembedfeature adds local ONNX models.
Implement MemoryStore and pass it to Memory::builder in place of the SQLite or in-memory store; nothing else changes. Run the conformance kit against your implementation (feature conformance of aidaemon-memory): aidaemon_memory::conformance::check_store(|| async { /* a fresh store */ }) reports which behaviours it satisfies.
Just recall
If you only want recall injected into each request, implement the small Recall trait and add MemoryInjection::new(your_recall) as a hook. Writing is model-driven in aidaemon-memory (FactExtractor, EpisodeSummarizer ask any Provider for typed JSON), and RememberTool / RecallTool let the agent decide for itself what to store.