Skip to content

Memory Module

Last updated: 2026-02-19 Status: Vertical slice complete — stores, embeddings, search, curation, tools all implemented and tested.

Architecture

The memory module gives AOF agents persistent, searchable knowledge. It follows a three-tier hot/warm/cold model with hybrid search (vector + full-text).

graph TD
TOOLS["Agent Tools<br>store / search / delete / list / get"] --> EMB["Embedding Provider<br>(OpenAI)"]
EMB --> VS["Vector Store"]
TOOLS --> VS
TOOLS --> FTS["FTS Store"]
TOOLS --> HS["Hybrid Search"]
VS --> HS
FTS --> HS

Tiers

TierPurposeLifecycle
HotActive working memory — recent, high-relevanceDefault for new entries
WarmAggregated knowledge — patterns, summariesPromoted from hot via WarmAggregator
ColdArchived incidents, historical contextDemoted from warm via ColdTier

Key Modules

ModulePathPurpose
index.tssrc/memory/index.tsModule registration, wires all components
Storessrc/memory/store/
schema.tsSQLite schema init (tables + FTS5 + vec0)
vector-store.tsVector similarity search (cosine via sqlite-vec)
fts-store.tsFull-text search (BM25 via FTS5)
hybrid-search.tsCombines vector + FTS scores with tier boosting
Embeddingssrc/memory/embeddings/
provider.tsEmbeddingProvider interface
openai-provider.tsOpenAI-compatible embedding client
Toolssrc/memory/tools/
store.tsmemory_store — ingest, chunk, embed, index
search.tsmemory_search — hybrid query with ranking
delete.tsmemory_delete — remove from all indexes
list.tsmemory_list — enumerate stored documents
get.tsmemory_get — retrieve specific file content
update.tsmemory_update — modify existing entries
indexing.tsIndexSyncService — background file watcher
Curationsrc/memory/
hot-promotion.tsRules for hot → warm promotion
warm-aggregation.tsAggregation policies for warm tier
cold-tier.tsCold archival + incident reports
curation-policy.tsConfigurable curation rules
curation-generator.tsGenerates curation configs from templates

Configuration

Memory is configured in the AOF plugin config:

{
"modules": { "memory": { "enabled": true } },
"memory": {
"embedding": {
"provider": "openai",
"model": "text-embedding-3-small",
"dimensions": 768
},
"poolPaths": {
"core": "~/.openclaw/aof/memory"
},
"defaultPool": "core",
"defaultTier": "hot",
"defaultLimit": 20,
"indexPaths": ["~/.openclaw/workspace/memory"],
"scanIntervalMs": 1800000
}
}

Key options

  • embedding.model — Any OpenAI-compatible embedding model
  • embedding.dimensions — Vector dimensions (must match model output)
  • poolPaths — Named directories for storing memory files
  • indexPaths — Directories to watch and auto-index
  • scanIntervalMs — Background sync interval (default: 30 min)

Usage

Store a memory

memory_store({ content: "The scheduler runs every 30s.", tier: "hot", tags: ["scheduler"] })

Writes a markdown file to the pool, chunks it, generates embeddings, and indexes in both vector and FTS stores.

memory_search({ query: "how does the scheduler work", limit: 10 })

Runs hybrid search: embeds the query, performs vector similarity + BM25 full-text, combines scores with tier boosting (hot > warm > cold).

Delete

memory_delete({ path: "/path/to/memory-file.md" })

Removes the file and all associated chunks from vector and FTS indexes.

List

memory_list({ limit: 20, tier: "hot" })

Returns stored documents with path, tier, pool, and timestamp metadata.

Testing

Terminal window
# Run all memory tests (147+ tests)
npx vitest run src/memory/
# Run integration test only
npx vitest run src/memory/__tests__/pipeline-integration.test.ts

Test coverage

AreaTest fileTests
Store toolmemory-store.test.tsWrite, chunk, index
Schemastore-schema.test.tsDB init, re-entrancy
FTSfts-store.test.tsIndex, search, delete
Vectorvector-store.test.tsInsert, update, delete, KNN
Embeddingsembeddings-provider.test.ts, openai-provider.test.tsEmbed, error handling
Searchmemory-search.test.tsQuery, filter, scoring
Hybridhybrid-search.test.tsCombined ranking
Chunkingchunker.test.tsMarkdown splitting
Pipelinepipeline-integration.test.tsEnd-to-end: store → search → delete
Curationhot-promotion.test.ts, warm-aggregation.test.ts, cold-tier.test.ts, curation-*.test.tsTier lifecycle