How Vector Search Gives Agents a Searchable Memory
Agents need facts that are not in the current prompt: policies, tickets, prior decisions, product docs, and runbooks.
Search across all documentation pages
Agents need facts that are not in the current prompt: policies, tickets, prior decisions, product docs, and runbooks.
Vector search turns that corpus into a searchable memory the model can query by meaning, not only by exact keywords.
A pretrained LLM only "remembers" what is in its weights and the current context.
Your product truth usually lives elsewhere: wikis, PDFs, tickets, SQL rows, and session logs.
Embeddings map text to fixed-length vectors so that similar meanings land near each other in high-dimensional space.
An embedding model is not a chat model.
It is specialized to encode queries and documents into comparable vectors (verify model ids and dimensions at build).
Similarity search ranks stored vectors by nearness to a query vector.
Common metrics include cosine similarity and Euclidean distance; stores often normalize vectors so cosine and inner product behave similarly.
RAG (Retrieval-Augmented Generation) is the pattern most agent teams mean by "searchable memory":
Without retrieval, the agent either hallucinates or you burn tokens stuffing the whole corpus into the window.
With retrieval, memory becomes queryable instead of always loaded.
That is the architectural difference between a chat log and a knowledge substrate.
| Layer | What it does | Agent-facing result |
|---|---|---|
| Chunk store | Holds original text slices | Evidence strings |
| Vector index | Approximate nearest-neighbor lookup | Ranked candidates |
| Metadata filters | Tenant, doc type, date, ACL | Scoped memory |
| Optional hybrid / rerank | Keyword + second-pass ranking | Higher precision |
| Tool / prompt packer | Formats hits for the model | Callable memory |
source, doc_id, tenant, updated_at, ACL tags).vector column / index in Postgres, etc.).# Conceptual shape (provider APIs vary - verify at build)
query_vec = embed("What is the refund window for annual plans?")
hits = vector_store.query(vector=query_vec, top_k=5, filter={"corpus": "policies"})
context = "\n\n".join(h.text for h in hits)
# agent prompt or tool result includes context + source idsFrom the model's point of view, tool results and retrieved passages are just more tokens.
From a systems point of view, you implemented associative recall: similar past content surfaces when the current task is similar.
That is different from:
Vector search excels at unstructured or semi-structured prose.
It is a poor sole store for "user's preferred language is Spanish" style atomic facts unless you also design extraction and structured tables.
Similarity alone is not authorization.
Always apply tenant and ACL filters in the store query so one customer's chunks cannot appear in another's agent context.
Treat retrieved text as untrusted content for prompt-injection risk (a doc can contain instructions that try to override the agent).
Patterns that work well:
search_knowledge tool the model invokes when uncertainPure always-on RAG is simpler.
Tool-callable retrieval is better when the agent also calls APIs, escalates, or acts.
Production agent memory stacks usually grow beyond "one collection, top_k=5":
| Concern | Technique | Trade-off |
|---|---|---|
| Exact codes / IDs | Hybrid BM25 + vector | Extra index to maintain |
| Noisy top-k | Cross-encoder or LLM re-rank | Latency and cost |
| Multi-corpus | Separate indexes or metadata partitions | Routing complexity |
| Freshness | Incremental upserts + updated_at filters | Stale embeddings after rewrites |
| Multilingual | Multilingual embed models | Model swap rebuilds the index |
| Eval | Hit-rate / MRR / faithfulness | Needs labeled questions |
Trade-offs among memory styles:
| Approach | Strength | Weakness | Best fit |
|---|---|---|---|
| Vector RAG | Semantic recall over large prose | Weak on exact tokens without hybrid | Docs, wikis, tickets |
| Full-text only | Exact match, simple ops | Misses paraphrase | IDs, error codes, SKUs |
| Structured DB / KV memory | Precise facts and preferences | Poor free-form narrative search | User profile, settings |
| Stuff-all-in-context | Simple, no index | Does not scale | Tiny fixed corpora |
| Fine-tuning | Bakes stable knowledge into weights | Costly, stale, hard to audit | Stable style, not live policy |
For multi-agent systems, share the same retrieval service with per-agent tool descriptions rather than embedding the corpus three times.
Keep embed model, chunker, and index build id versioned so "why did answer quality change?" is answerable.
A list of numbers that represents the meaning of a text span so similar spans have similar numbers. Distance in that space approximates semantic relatedness.
Keyword search matches tokens and stems. Vector search matches meaning, so "return window" can retrieve "refund policy within 30 days" even without shared words. Hybrid systems use both.
Only if you design it that way. Many products vectorize documents and selected memory extracts, not every chat turn. Logging all turns into one index can leak privacy and create noise.
The number of nearest chunks returned from the index for a query. Typical agent tools use small k (3-10) before packing context.
Embedding models and prompts have size limits, and whole-document vectors blur local details. Chunks make retrieval more precise and packable.
No. Stores support several metrics. What matters is consistency between how vectors were built and how the index is configured (verify at build).
Yes, with extensions such as pgvector for many workloads. Dedicated services trade ops simplicity or scale features for less DIY work. See the store comparison page in this section.
After a cheap first-pass retrieval returns candidates, a re-ranker reorders them for higher precision before the agent sees them.
Usually as a tool: name, description, and arguments (query string, filters). The host embeds, queries the store, and returns text + metadata to the model.
Mismatched embed models, no metadata filters, giant unchunked docs, and no eval set - not the choice of logo on the vector product.
No. RAG retrieves live context at inference. Fine-tuning changes model weights. Many products use RAG for facts and fine-tuning (if at all) for style or format.
Re-ingest changed sources, delete superseded chunk ids, and record corpus versions. Prefer incremental pipelines over full rebuilds when the store supports them.
No. Use SQL (or APIs) for orders, balances, and authoritative state. Use vectors for prose and fuzzy knowledge around that state.
Query text, filters, hit ids, scores, chunk previews, embed model id, and whether the agent actually used the tool. Final prose alone is not enough.
Stack versions: Pins from the category manifest (verify at build): OpenRouter (~315+ models, July 2026 pricing/fees); LangGraph 1.0+; CrewAI 1.14+; Microsoft Agent Framework 1.0; Vercel AI SDK 6; Pydantic AI (latest); LlamaIndex (latest); OpenAI Agents SDK (latest + MCP); MCP (Linux Foundation governance); A2A (HTTP+SSE+JSON-RPC 2.0); Solana
@solana/web3.js+@solana/spl-token.
Reviewed by Chris St. John·Last updated Jul 16, 2026