Infinite memory, explained
ɳClaw uses pgvector embeddings and Postgres ltree paths to build a self-organizing knowledge graph from every conversation. Here's how it works from first message to living knowledge base.
Embedding dimensions
1 536
Index type
HNSW (pgvector)
Topic hierarchy
ltree (Postgres)
Search modes
vector + full-text
Cache
Redis (recent context)
Disk estimate
~6 KB per message
Every message becomes a vector
When you send a message, the ai plugin passes it through an embedding model. The embedding is stored in Postgres with pgvector, a 1536-dimensional vector that captures semantic meaning. Every message in every conversation lives alongside its vector.
-- pgvector stores your memories
CREATE TABLE np_messages (
id UUID PRIMARY KEY,
session_id UUID NOT NULL,
content TEXT NOT NULL,
embedding vector(1536),
topic_path ltree,
created_at TIMESTAMPTZ DEFAULT now()
);Topics emerge automatically
After 3 messages, the claw plugin runs a topic-detection pass. It clusters the recent message vectors using k-means (or cosine similarity to existing topics) and assigns a label. If the topic is new, it creates a node in the ltree hierarchy. If it matches an existing topic, the conversation branches from that node.
-- ltree makes topic paths queryable
-- "work.project.backend" is a child of "work.project"
UPDATE np_messages
SET topic_path = 'work.project.backend'
WHERE id = $1;
-- Find all messages in a topic subtree
SELECT * FROM np_messages
WHERE topic_path <@ 'work.project';Related topics link automatically
Every topic in your knowledge graph has a centroid vector, the average of all message embeddings within it. When a new topic is detected, ɳClaw finds the nearest existing topics by cosine distance. Topics within a similarity threshold are linked in the graph. This is how work conversations from six months ago connect to a project you just started.
-- Find related topics by vector similarity
SELECT topic_path, 1 - (centroid <=> $1::vector) AS similarity
FROM np_topic_centroids
WHERE 1 - (centroid <=> $1::vector) > 0.75
ORDER BY similarity DESC
LIMIT 5;The graph compounds over time
Unlike a flat chat history, ɳClaw's knowledge graph grows richer with use. Past conversations inform future ones. If you've discussed a project ten times over three months, ɳClaw has a dense cluster of related memories it can draw from. Ask "what was I thinking about this last March?" and it searches the vector index, not your memory.
-- Context retrieval for a new message
SELECT content, 1 - (embedding <=> $1::vector) AS relevance
FROM np_messages
WHERE topic_path <@ $2::ltree
ORDER BY relevance DESC
LIMIT 20;See it live
The demo lets you watch the topic graph build in real time. Send 3 messages and see your first auto-detected topic appear.