# Vector Memory

> Store memories as embeddings in a vector index and retrieve the most semantically similar items at query time — so relevance is judged by meaning, not keyword match or recency.

- **Category**: Agentic AI
- **Subcategory**: Memory
- **Canonical URL**: https://designpattern.fyi/patterns/vector_memory/

---

## Description
**Intent**: Store memories as embeddings in a vector index and retrieve the most semantically similar items at query time.
**Context**: A long-running agent accumulates facts and observations over time. On each step it needs to find the small subset of past items most relevant to the current situation. Relevance is best judged by semantic similarity, not exact term match or chronological recency — "find past notes whose meaning is closest to what's happening now."
**Solution**: Embed and index each memory item. At query time, embed the query (or a summary of current state), retrieve the top-k most similar memories, and prepend to context. Optionally apply decay (boost recent, age old) and salience weighting.



## Use Cases
- A long-running agent accumulates facts whose relevance is best judged by semantic similarity.
- An append-only log would otherwise grow unboundedly without selective retrieval.
- An embedding model and vector index can be deployed and maintained.






## Trade-offs


### Advantages

- Semantically relevant past surfaces automatically — no explicit query planning needed.

- Scales to memory stores far too large to fit in context.




### Considerations & Drawbacks

- Misses purely temporal queries ("what did I do yesterday?") — vector similarity doesn't capture chronology.

- Embedding drift on model or schema changes can silently degrade retrieval quality.







---
**Reference**: [Original Source](https://www.agentpatternscatalog.org/patterns/vector-memory/)

