Vector Databases & RAG Best Practices
Ten practices for chunking, indexing, retrieving, and operating vector-backed agent memory so answers stay grounded, scoped, and measurable.
Search across all documentation pages
Ten practices for chunking, indexing, retrieving, and operating vector-backed agent memory so answers stay grounded, scoped, and measurable.
Use this list when launching a RAG agent or when fluency rises while factual accuracy slips after a corpus change.
doc_id, source, tenant/ACL tags, and freshness fields; inherit them through the pipeline.candidate_k, re-score, keep small top_n; drop re-rank if latency or cost wins over measured gain. See Re-Ranking Retrieved Results Before Passing Them to an Agent.| Stage | Habits | Exit criterion |
|---|---|---|
| Design | 1-3 | Corpus layout, chunker, and versioning written |
| Implement | 4-7 | Scoped tool + retrieval stack matches workloads |
| Launch | 8-9 | Eval gates + injection-aware handling live |
| Operate | 10 | Ingest/serve split and traces in prod |
"search everything".# Pattern: pin config + filtered search + structured tool result
INDEX = {
"embed_model": "text-embedding-3-small", # verify at build
"chunker": "recursive-md@v3",
"build_id": "2026-07-01.1",
}
def search_knowledge(query: str, top_k: int = 4) -> dict:
# tenant from auth context - not from model args
hits = hybrid_search(query, top_k=top_k, filters={"tenant": current_tenant()})
return {
"ok": True,
"index_build_id": INDEX["build_id"],
"results": [
{"id": h.id, "text": h.text[:2000], "metadata": h.metadata}
for h in hits
],
}Pinned ingest versions (1), server-side tenancy filters (4), and retrieval eval gates (8). Without them, agents sound confident while drifting or leaking.
No. Start with solid chunks and filters. Add hybrid when exact tokens fail; add re-rank when evals show ranking, not recall, is the bottleneck.
On corpus change, embed/chunker change, or scheduled freshness jobs for living documents. Measure before/after hit-rate.
Ops and cost change; the ten habits stay. Pick stores with Choosing a Vector Store: Pinecone, Chroma, and pgvector Compared.
Detect empty or low-quality hits and force refuse/escalate tools instead of free-form generation.
Embed/chunker pins, filter enforcement, tool descriptions, eval deltas, and that request paths cannot rebuild indexes inline.
It is fine for pure Q&A bots. Multi-tool agents usually want optional retrieval tools so not every turn pays search cost.
Keep atomic preferences and profile facts in structured stores; use vectors for prose. See the long-term memory section for extraction and conflicts.
Related: How Vector Search Gives Agents a Searchable Memory
Related: Vector Databases & RAG Basics
Related: Choosing a Vector Store: Pinecone, Chroma, and pgvector Compared
Related: Building a Retrieval Tool an Agent Can Call
Related: Chunking Strategies That Affect Retrieval Quality
Related: Hybrid Search: Combining Vector Similarity with Keyword Filters
Related: Re-Ranking Retrieved Results Before Passing Them to an Agent
Related: LlamaIndex Best Practices
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