FIELD NOTE 018 / AGENT MEMORY
The Vector Memory Fallacy: 3-Tier Agent Store
Why raw vector search fails for long-term agent memory, and how a 3-tier cognitive architecture solves state, time, and causality.
By Harrison Ndeke · Published September 3, 2026 · Updated September 24, 2026 · 11 min read
COGNITIVE STORE
EPHEMERAL KV → BI-TEMPORAL SQL → HYBRID VECTOR
DIRECT ANSWERTreating cosine similarity over embedding vectors as agent memory is an architectural fallacy. Vector search provides semantic correlation without temporal awareness, causal grounding, or exact key-value retrieval. Production autonomous systems require a 3-tier cognitive store combining ephemeral working memory (Redis / in-memory KV), bi-temporal event logs (PostgreSQL with RLS), and hybrid sparse-dense retrieval (pgvector + BM25 full-text indexing).
Key takeaways
- Vector similarity is not episodic memory: High semantic similarity does not imply factual recency, logical causality, or truth.
- The temporal blindness problem: Plain vector databases cannot distinguish an event that happened five minutes ago from one that happened three years ago without metadata filtering.
- Key-value facts demand exact lookups: Customer IDs, order statuses, and API tokens should never be retrieved via approximate nearest neighbor (ANN) vector search.
- The 3-tier cognitive store solution: Separate working state (Tier 1), durable structured ledger (Tier 2), and semantic associative memory (Tier 3).
- Hybrid search eliminates false positives: Combining BM25 sparse keyword scoring with dense vector embeddings yields 30–40% higher precision in production RAG systems.
Why raw vector databases fail as agent memory
| Memory Requirement | Raw Vector Search Behavior | 3-Tier Cognitive Store Behavior |
|---|---|---|
| Exact State Lookup | Returns approximate semantic nearest neighbor (can hallucinate wrong user ID) | Direct primary-key SQL / Redis lookup with deterministic schema guarantee |
| Temporal Order | Blind to time; ranks 2-year-old stale policies equally with yesterday’s update | Bi-temporal audit timestamps with recency decay weighting and valid-time ranges |
| Causal Reasoning | Lacks parent-child relationship graphs between actions and outcomes | Structured event ledger tracking execution graphs and trace correlation IDs |
The 3-tier cognitive store architecture
- Tier 1 — Ephemeral Working Memory: Fast in-memory key-value store holding active session context, token budgets, and current turn state. Discarded upon task completion.
- Tier 2 — Bi-Temporal Structured Ledger: PostgreSQL database storing transactional audit records, user profiles, tool call histories, and human approval logs with timestamp versioning.
- Tier 3 — Hybrid Associative Memory: pgvector semantic database combined with BM25 full-text search, restricted by row-level security (RLS) and strict tenant isolation.
-- Hybrid Search in Supabase Postgres (Dense + Sparse)
create or replace function match_agent_memory(
query_embedding vector(1536),
query_text text,
match_count int,
user_uuid uuid
)
returns table (
id bigint,
content text,
similarity float
)
language plpgsql
as $$
begin
return query
select
m.id,
m.content,
(0.7 * (1 - (m.embedding <=> query_embedding)) +
0.3 * ts_rank_cd(to_tsvector('english', m.content), plainto_tsquery('english', query_text))) as similarity
from agent_memories m
where m.user_id = user_uuid
order by similarity desc
limit match_count;
end;
$$;Cognitive store engineering checklist
- Are exact entity lookups routed to SQL/KV rather than vector embeddings?
- Does semantic retrieval apply time-decay weighting or metadata date bounds?
- Is tenant isolation enforced via Postgres Row Level Security (RLS)?
- Is hybrid sparse-dense search enabled to prevent lexical misses?
- Are agent trajectories stored in append-only event logs?
Executive summary
Building autonomous AI agents that remember users across days, weeks, and complex multi-turn workflows requires abandoning simplistic vector-only memory patterns. A production cognitive store combines fast ephemeral KV state, durable bi-temporal SQL records, and hybrid vector search into a coherent, queryable architecture.
Related services and reading
- Supabase Developer Kenya for Postgres, pgvector, and RLS architecture.
- Supabase for AI for production RAG and pgvector indexing.
- RAG Explained for retrieval pipelines.
About the author
Harrison Ndeke is an AI systems developer in Nairobi specializing in Supabase, pgvector, and multi-tier agent memory architectures.