Architecture
memory engine
SQLite hybrid search with FTS5, BM25, and vector similarity
design
no pinecone, no elasticsearch, no langchain. custom hybrid search built on SQLite.
search pipeline
- FTS5 keyword search — full-text search with BM25 ranking
- vector cosine similarity — embedding-based semantic search
- weighted hybrid merge — combines both result sets with configurable weights
- LZ4 compression — entries over 1KB are automatically compressed
embedding cache
LRU cache with configurable size. prevents redundant embedding API calls for frequently accessed entries.
[memory]
max_entries = 10000
embedding_cache_size = 1000
agent tools
the agent interacts with memory through two tools:
- memory_store — save information with automatic embedding
- memory_recall — hybrid search across all stored entries
implementation
#[async_trait]
pub trait Memory: Send + Sync {
async fn store(&self, key: &str, value: &str) -> Result<()>;
async fn recall(&self, query: &str, limit: usize) -> Result<Vec<MemoryEntry>>;
async fn forget(&self, key: &str) -> Result<()>;
}
the default SQLite implementation uses parking_lot::Mutex for thread-safe access without poisoning overhead.