Cognitive memory for AI agents: how SQLite replaced vector databases

A developer has unveiled an open cognitive memory architecture for local AI agents, built on top of a single SQLite file. Instead of the standard vector database approach, the system uses a graph model with episodic and semantic nodes, plus hybrid search that combines FTS5, vectors, and graph traversal, ranked with Reciprocal Rank Fusion. It also applies the Ebbinghaus forgetting curve so information ages out automatically. Background LLM consolidation lets the agent generalize from accumulated experience. The full code and SQL schema are available in an open repository.

AI-processed from Habr AI; edited by Hamidun News
Cognitive memory for AI agents: how SQLite replaced vector databases
Source: Habr AI. Collage: Hamidun News.
Listen to article

One of the biggest unsolved problems with today's AI agents sounds deceptively simple: how do you teach them to remember what matters and forget what's out of date? A developer who published a detailed technical breakdown on Habr has proposed a solution that runs against the industry mainstream. Instead of reaching for a popular vector database, he built a full cognitive memory system on top of a single SQLite file.

The problem he describes will be familiar to anyone who has tried to build a long-lived AI agent. The standard recipe goes like this: take text, split it into chunks, turn the chunks into vector embeddings, store them in Pinecone or Chroma, and at query time pull the nearest neighbors by cosine distance. Over short horizons, this works. But once an agent runs for a while, things fall apart: irrelevant fragments clutter the context window, contradictory facts from different periods sit side by side as if nothing were wrong, and there is simply no mechanism for forgetting. The agent remembers everything equally well, which in practice means it remembers everything equally badly.

The proposed architecture borrows principles from cognitive psychology and neuroscience. Memory is organized as a graph with two types of nodes: episodic nodes, which store specific events and interactions, and semantic nodes, which hold generalized knowledge and facts. Typed edges connect the nodes and capture the nature of each relationship. Named entities live in a separate layer, which lets the agent track mentions of specific people, organizations, and concepts and stitch scattered pieces of information into a coherent picture.

The search system deserves special attention. Rather than relying on a single retrieval method, the developer implemented a hybrid approach that combines three mechanisms: full-text search via SQLite FTS5 for exact matches and keywords, vector search for semantic similarity, and graph traversal to pull in related context. The results of the three strategies are merged using Reciprocal Rank Fusion, an algorithm that combines ranked lists from different sources without needing to calibrate their absolute scores. It's an elegant solution that lets each method compensate for the weaknesses of the others.

But the most interesting part of the architecture isn't about remembering — it's about forgetting. The developer implemented the Ebbinghaus forgetting curve, a classic 19th-century model from experimental psychology that describes how memory decays exponentially over time. Every node in the graph has a "memory strength" score that gradually declines. Information that gets accessed repeatedly is reinforced, while rarely used fragments naturally fade into the background. This is fundamentally different from most systems, where data either exists or it doesn't.

A background LLM consolidation mechanism rounds out the design. Much as the human brain processes and generalizes information during sleep, the agent periodically runs a language model over its accumulated episodic memories. The model spots patterns, resolves contradictions, and creates new semantic nodes, turning scattered episodes into structured knowledge. In effect, it automatically generates "wisdom from experience."

The engineering pragmatism here is worth stressing. The whole system runs on a single SQLite file — no external services, no Docker containers running vector databases, no cloud storage subscriptions. For a locally running agent, that means minimal dependencies, easy deployment, and full control over the data. Despite its reputation as a "database for small projects," SQLite has long since proven it can handle serious workloads, and the FTS5 extension turns it into a full-fledged search engine.

The project fits a growing trend toward more "human-like" memory for AI agents. Major labs such as Google DeepMind and OpenAI are actively researching long-term memory mechanisms, but their solutions are usually tied to proprietary platforms. An open architecture that anyone can deploy locally on any machine democratizes access to these capabilities. If the approach holds up at scale, it could change how we think about memory for autonomous agents, shifting from mindless data hoarding to deliberate knowledge management.

Story
ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Unified AI Workspace · Nomad

Test Frontier LLMs & Autonomous Agents in One Workspace

Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.

Try Nomad AI →Launch Nomad Agent
What do you think?
Loading comments…