為何向量資料庫難以勝任 AI 智能體記憶
Why Vector Databases Make Terrible Agent Memories
向量資料庫不適合作為 AI 智能體的持久記憶,因為語義相似度無法判斷事實是否仍有效,也難以掌握狀態變化與事件先後。多輪智能體基準研究顯示,少於 2% 的記憶框架能處理動態遺忘或狀態修剪。搜尋適合檢索靜態資料,記憶則需要追蹤現況、變更時間及導致決策的過往事件。
If you've spent any time building autonomous agents recently, you've probably run into the exact same wall:
How do you give an AI persistent memory?
The standard recipe everyone gives you is pretty straightforward:
- Save every message or interaction.
- Chunk the text into 500-token blocks.
- Generate embeddings and store them in a vector database (Pinecone, Chroma, Qdrant, pgvector).
- When the user sends a new message, query the database for the top-k most relevant chunks.
- Stuff those chunks into the system prompt.
On paper, this sounds reasonable. It's cheap, easy to set up, and works in weekend demos.
In production, it falls apart fast.
Here is why vector databases fail when used as an agent's memory—and what the industry is getting wrong about state.
1. Semantic Similarity Has No Concept of Truth
The fundamental premise of vector search is: "Find text that sounds similar to this query."
The problem? Similarity is not truth, and similarity is definitely not state.
Consider a simple, real-world example:
- Day 1: User says: "We are using Postgres for our primary database."
- Day 4: User says: "Postgres didn't scale for this service, we migrated everything to ClickHouse yesterday."
- Day 6: User asks: "Which database should I write this migration script for?"
The system embeds the question: "Which database should I write this migration script for?"
What does the vector database return?
Both chunks contain high semantic overlap with "database", "service", and "migration".
In fact, the Day 1 chunk might have a higher cosine similarity score because it contains the exact word "primary database".
The agent reads both, gets confused, and hallucinates:
"You are using Postgres as your primary database, but also migrating to ClickHouse."
The vector database did its job perfectly. It found similar text. But it had no mechanism to know that Day 4 invalidated Day 1.
2. The Append-Only Dilemma
Human brains and real systems don't just record—they overwrite and prune.
When you move to a new apartment, your brain doesn't keep your old address as an equal alternative in active recall. The new fact supersedes the old one.
Vector search is fundamentally append-only:
- Every update is just another chunk added to an index.
- There is no native
UPDATEorDELETEbased on real-world facts unless you manually write fragile regex parsers or run extra LLM passes on every single write. - As the conversation spans weeks, the database fills up with outdated decisions, dead-end bugs, and discarded ideas.
Recent studies on multi-session agent benchmarks show that less than 2% of agent memory frameworks handle dynamic forgetting or state pruning. The rest suffer from what engineers call "context rot": the longer the agent runs, the noisier and dumber it gets.
3. Time Does Not Live in an Embedding
Vectors live in spatial dimensions. They measure proximity in a high-dimensional space.
They have no timeline. They don't know:
- What happened before vs. after.
- Cause and effect.
- The order of operations in an incident response.
If you ask an agent:
"What decision did we make after the server crashed, but before we notified customers?"
A vector search cannot solve this problem through similarity alone. It pulls chunks containing "server crash", "decision", and "customers"—regardless of when they actually occurred in the timeline.
To fix this, developers end up wrapping vector databases in layers of metadata filters, timestamp tags, and secondary relational tables.
At that point, you aren't really using vector search anymore. You're building a makeshift relational database with extra latency.
4. Memory Is Not Search
We need to stop confusing search with memory.
- Search (RAG): Great for looking up static documentation, reading an API reference, or scanning an internal handbook. The data doesn't change every five minutes, and sequence rarely matters.
-
Memory: Dynamic, stateful, and chronological. It needs to know:
- What is the current ground truth?
- When did this state change?
- What past events led to this decision?
- What details are now obsolete and can safely be forgotten?
Sticking a vector database next to a language model and calling it "long-term memory" is like taping a filing cabinet to a worker's back and claiming they have an eidetic memory. Every time they need to do something, they have to stop, dig through paper files, and hope the top sheet isn't out of date.
What Comes Next?
Over the past two years, the AI ecosystem went through two big phases:
- Make context windows bigger (which hit the KV cache memory wall).
- Attach vector databases to everything (which hit the temporal and state wall).
Both approaches try to solve the same problem from the outside in—treating the model as a frozen, stateless black box and stuffing more text into the prompt.
Real autonomous systems won't be built by chaining more search queries together. They need architectures that treat time and state as native dimensions, not afterthought metadata tags.
Until that happens, your AI agent isn't actually remembering anything. It's just searching its own history and hoping for the best.
來源:DEV Community · dev.to