Skip to content
Go back

AgenticMemory, Part 2: How the Agent Searches and Knows What Matters

Published:
• 8 min read Edit on GitHub

Yesterday we covered the foundation: the binary file, portability, typed events, reasoning chains. If you missed it, start with Part 1.

Today is about what happens when the agent uses that memory. How it handles being wrong. How it finds what it needs. How it figures out what actually matters.


5. Self-Correction Without Data Loss

SUPERSEDES edges — the agent can be wrong without lying about it

This one took me a while to think through correctly. When an AI learns something new that contradicts something it already stored, it has two bad options: keep both (confusion) or overwrite the old one (data loss). Most systems pick one of those and live with the consequences.

Neither is right.

Consider this: “User works at Google.” Then later: “User works at Meta.” Which is true? When did it change? With a flat store, you have no idea. Either the old entry is gone, or both exist and the agent has to guess which to use.

The naive approach
Fact: User works at Google
Fact: User works at Meta
History: gone. Audit trail: none.
SUPERSEDES chain
Fact: User works at Google [confidence: 0]
SUPERSEDED_BY ↓
Fact: User works at Meta [confidence: 1]

AgenticMemory uses SUPERSEDES edges. When a new fact replaces an old one, the old fact is not deleted. Its confidence drops to zero. A Correction node is created and linked to both. The chain is preserved, queryable, traversable.

Ask “where does the user work?” and the system follows the chain to the latest version. Ask “where did they used to work?” and the full history is right there. Every change, timestamped, in order.

No data loss. No confusion. Full audit trail that a compliance team could actually read.


Fast exact-term search over all memories in under 20 milliseconds

Vector search is what everyone reaches for when they want to search AI memory. Embed the query, find semantically similar memories, return the top results. It works for vague, exploratory questions. It fails badly for exact matches.

Search “Kubernetes” in a vector store and you might get back results about “container orchestration” or “cluster management” that never mention Kubernetes once. The semantic meaning overlaps but the exact word is not there.

How BM25 works in .amem
1
Every word in every memory is indexed in an inverted index inside the .amem file
2
Query “Kubernetes” hits the index directly, returns every memory that contains the word
3
Results ranked by BM25 score — rare terms weighted more than common ones

<20ms on 100,000 memories. No external service.

BM25 runs directly on the binary memory file. An inverted index maps every word to every node that contains it. “Kubernetes” returns every memory that actually says “Kubernetes,” ranked by how often it appears and how rare the term is across the full graph. No embeddings. No API call. No external service.

In plain terms: right now, searching your AI’s memory is hoping the librarian understands what you mean. After this, you can just say the word and get every memory that uses it.


BM25 and vector search running together, results fused into one ranking

The honest answer is that neither exact-term search nor semantic search is complete on its own. BM25 catches the exact word but misses the related concept. Vector search catches the concept but misses the exact term. You need both.

Hybrid search runs them in parallel. BM25 produces a ranked list. Vector similarity produces a ranked list. Reciprocal Rank Fusion combines them: a memory that ranks at the top in both signals gets the highest combined score. A memory that ranks near the top in one but not the other still surfaces, because one strong signal is worth something.

One query. Both signals. The result is better than either alone because you are not choosing between them.

In plain terms: right now, you can search your email by exact words or by vibe, but not both at once. After this, the search uses both signals simultaneously and ranks the results by their combined strength.

The technical detail worth noting: Reciprocal Rank Fusion does not require you to normalize the scores from two different systems. It works on ranks, not raw scores, which makes it robust to the different scales that BM25 and vector similarity use.


8. Graph Centrality

PageRank on beliefs — find what everything else is built on

This is the one that changes how you think about what a memory system is for.

Right now, no memory system can tell you which memories are the most important. Every stored fact has equal weight. A throwaway preference note has the same status as the foundational belief that fifteen decisions were built on. There is no way to ask “what does this agent believe most deeply?” because there is no concept of depth.

Centrality score — which beliefs matter
Fact: Team cannot adopt Rust
0.91 — 15 decisions depend on this
Fact: Budget capped at $3k/mo
0.64 — 9 decisions
Fact: User prefers dark mode
0.04 — 0 decisions

AgenticMemory runs PageRank on the knowledge graph. The same algorithm Google used to rank the web, now applied to beliefs. A Fact with fifteen Decisions pointing to it through CAUSED_BY edges has a high centrality score. A Fact that nothing depends on has a low one. The agent can answer: “What are the core beliefs that everything else in my knowledge about this user is built on?”

In plain terms: right now, all your AI’s memories are sticky notes on a wall with no hierarchy. After this, it knows which sticky notes are load-bearing. Remove one of those, and the whole structure shifts.

This matters when things change. If a foundational belief turns out to be wrong, centrality tells you how much of the agent’s reasoning is affected before you make any corrections.


Four more down. Two posts left.

Tomorrow is where things get genuinely new territory — capabilities that required the typed cognitive graph to even be possible. Counterfactual propagation, structural gap detection, analogical reasoning across domains.

← Part 1: The Foundation
Part 2 of 4
Part 3: Novel Capabilities →
Source
github.com/agentic-revolution/agentic-memory
pip install agentic-memory
Share this post on:

New posts, research updates, and nerdy links straight to your inbox.

2× per month, pure signal, zero fluff.

Go back