Skip to main content

Memory Tools

NullClaw provides four memory tools that enable agents to store and retrieve long-term facts:
  • memory_store — Persist facts to long-term memory
  • memory_recall — Search memory with hybrid retrieval
  • memory_list — List all stored memories
  • memory_forget — Delete memory entries
Memory tools support:
  • Multiple backends — SQLite, Markdown, None
  • Hybrid search — BM25 + vector similarity with RRF merge
  • Temporal decay — Recent memories weighted higher
  • MMR diversification — Avoid redundant results
  • Vector sync — Automatic embedding sync to vector store

Memory Architecture

Memory Backend

Memory tools operate on a pluggable Memory backend:

Memory Categories

Memories are organized into three categories:
Usage guidelines:
  • core — User preferences, stable facts (e.g., “User prefers Zig”)
  • daily — Temporary session notes (e.g., “Working on feature X today”)
  • conversation — Key conversation excerpts (use sparingly)
Do not store routine greetings or every chat message in memory. Only store important facts and decisions.

Hybrid Retrieval Pipeline

When a MemoryRuntime is available, memory_recall uses a sophisticated retrieval pipeline:
  1. BM25 full-text search — Exact keyword matching
  2. Vector similarity search — Semantic similarity via embeddings
  3. RRF merge — Reciprocal Rank Fusion combines rankings
  4. Temporal decay — Recent memories boosted
  5. MMR diversification — Remove redundant results
Without MemoryRuntime:
Falls back to raw mem.recall() (BM25 only)

memory_store

Persist facts to long-term memory with automatic vector sync.

Parameters

string
required
Unique key for this memory (used for updates and deletion)
string
required
The information to remember
string
default:"core"
Memory category: core, daily, or conversation

Configuration

Usage

Store a core fact:
Response:
Store a daily note:
Response:

Vector Sync

When mem_rt is configured, stored memories are automatically:
  1. Embedded via configured embedding provider
  2. Upserted to vector store (e.g., Qdrant, Chroma)
  3. Available for semantic search in memory_recall
Sync is best-effort and does not block on failure.

Duplicate Keys

Storing with an existing key overwrites the previous content:
Later:
memory_recall now returns “Project completed” for key “status”.

Source

src/tools/memory_store.zig:12-61

memory_recall

Search long-term memory for relevant facts using hybrid retrieval.

Parameters

string
required
Keywords or phrase to search for in memory
integer
default:5
Maximum results to return (1-100)

Configuration

Usage

Search for facts about Zig:
Response:
No results:
Response:

Hybrid Search Results

When mem_rt is configured, results include hybrid scores:
Scores indicate:
  • bm25 — Exact keyword match
  • vector — Semantic similarity
  • Higher score = better match

Internal Memory Filtering

Memories with keys starting with __bootstrap. are filtered from results:
memory_recall("Zig") returns only user_pref, not bootstrap internals.

Source

src/tools/memory_recall.zig:14-163

memory_list

List all stored memories (optionally filtered by category).

Parameters

string
Filter by category: core, daily, or conversation

Configuration

Usage

List all memories:
Response:
List core memories only:
Response:

Source

src/tools/memory_list.zig

memory_forget

Delete a memory by key with automatic vector store cleanup.

Parameters

string
required
The key of the memory to forget

Configuration

Usage

Delete a memory:
Response:
Key not found:
Response:

Vector Store Cleanup

When mem_rt is configured, memory_forget automatically:
  1. Deletes the memory from the primary backend (SQLite/Markdown)
  2. Deletes the corresponding vector embedding from the vector store
Cleanup is best-effort and does not block on failure.

Source

src/tools/memory_forget.zig:11-57

Memory Backends

SQLite Backend

Features:
  • BM25 full-text search via SQLite FTS5
  • Category filtering
  • Metadata support
  • Persistent across restarts

Markdown Backend

Features:
  • Human-readable markdown file
  • Simple key-value structure
  • Substring search (not BM25)
  • Great for debugging

None Backend (No-Op)

Features:
  • All operations are no-ops
  • Useful for testing without persistence
  • Store/recall return empty results

Memory Runtime

For hybrid search with vector embeddings, configure a MemoryRuntime:
Bind to tools:

Retrieval Parameters

  • k — Number of candidates from each method (BM25, vector)
  • bm25_weight — Weight for BM25 scores in RRF merge (default: 0.6)
  • vector_weight — Weight for vector scores in RRF merge (default: 0.4)
  • temporal_decay_days — Days after which memory score decays by 50% (default: 30)
  • mmr_lambda — MMR diversification parameter (0 = max diversity, 1 = max relevance)

Use Cases

User Preferences

Project Context

Conversation Highlights

Recall During Task

Response:

Testing

Run memory tool tests:
Tests cover:
  • Store/recall/list/forget operations
  • Category filtering
  • Hybrid search with MemoryRuntime
  • Internal memory filtering
  • No backend (NoneMemory) behavior