On this page

These vector database mistakes are the most common immediate causes of retrieval failures that make coding agents produce incorrect or unsafe outputs. Eight patterns cause most incidents: metric mismatches between query and index, unnormalized embeddings, chunks sized wrong for code structure, stale indexes after model upgrades, missing tenant or repository filters, poisoned documents in the corpus, reliance on average recall instead of tail metrics, and no verification gate before an agent acts on retrieved content.
Run two checks before anything else:
- Pull
vec_countandvec_failedfrom your index and confirm the numbers match what your ingestion pipeline actually wrote. - Fire five to ten known smoke queries with expected top-k results and see if recall holds.
Pro Tip: Stand up a small exact-search index (brute-force cosine, no ANN) and shadow 1% of live traffic against it. Comparing ANN results to exact results on that slice is the fastest way to catch tail recall problems before users do.
Key Takeaways
Vector database mistakes break retrieval quietly, and the fix requires tail-aware metrics, tenant-aware filtering, and a verification step before agents act on what they retrieve.
| Point | Details |
|---|---|
| Check metric and normalization first | Confirm embedding dimensions and normalization match what the index expects before debugging anything else. |
| Track tail recall, not just averages | Monitor Robustness-δ@K and segment recall by query frequency to catch failures average recall hides. |
| Filter-aware indexing prevents empty hits | Push filters into tenant-local collections or pre-materialized postings instead of post-filtering ANN results. |
| Shadow before you cut over | Run new embeddings or index parameters against 1% of live traffic before retiring the old index. |
| Verify before agents act | Add a dry-run or human approval step before any retrieved content triggers a state-changing command. |
Table of Contents
- Vector Database Mistakes: Wrong Embeddings, Bad Chunking, and Stale Indexes
- Filter and Access Control Failures That Crater Recall
- Which Metrics Actually Catch Silent Retrieval Failures?
- A Copy-Ready Runbook for Vector Retrieval Incidents
- When Bad Retrieval Leads to Unsafe Agent Actions
- What This Failure-by-Industry View Gets Right About Coding Agents
- Sources
- FAQ
Vector Database Mistakes: Wrong Embeddings, Bad Chunking, and Stale Indexes
Most retrieval failures in coding agents trace back to three root causes, and none of them throw an error. The system returns results. They’re just wrong, and nothing in your logs screams about it.

Metric mismatch is the quiet killer. If your embedding model was trained for cosine similarity but your index runs L2 distance, or vice versa, you get results that look plausible and rank badly. Check two things at write time: the vector dimension count matches what the model actually outputs, and normalization is enforced consistently. A model that emits unnormalized vectors mixed into an index expecting unit-length vectors will silently distort every similarity score. This isn’t a rare misconfiguration. The Milvus HNSW recall cliff issue documents how embedding quality problems, including vectors with unexpectedly high proportions of zero dimensions, combine with index parameter choices to produce reproducible drops in recall that look like index bugs but are actually data quality bugs.
Chunking is where code retrieval specifically goes wrong. Natural-language chunking heuristics (fixed token windows, paragraph splits) break function boundaries and separate a method signature from its body. Chunk too big and you dilute the embedding with irrelevant surrounding code; chunk too small and you lose the context an agent needs to understand what a function does. Test chunking changes the same way you’d test a code change: with targeted smoke queries where you already know the expected file and function should surface in the top three results.
Index staleness follows every embedding model upgrade. Swap embedding models without reindexing and you get vectors from two different geometries living in the same index, comparing distances that mean nothing to each other. The fix is a shadow index: dual write to both the old and new embedding spaces, run parallel recall checks, and only cut over once the new index matches or beats the old one on your smoke tests. Sampling head, torso, and tail queries during this comparison surfaces index access pattern mismatches that a single aggregate recall number hides completely.
Filter and Access Control Failures That Crater Recall
Metadata filters and tenant isolation are where a lot of RAG systems for coding agents quietly stop working, especially in monorepos or multi-repository setups where an agent should only see certain codebases.
The core problem is when filtering happens. Post-filtering runs the ANN search first, then discards results that don’t match the tenant or repo filter, which means a highly selective filter can return an empty result set even when matching documents exist elsewhere in the index. Pre-filtering narrows the candidate set before the ANN search runs, but naive implementations create what practitioners call disconnected ANN islands: the graph-based index structure (like HNSW) assumes connectivity across the whole space, and a narrow filter can isolate a pocket of vectors the search never reaches. The Architect’s Brief on vector DB failures walks through exactly this failure mode in production multi-tenant systems.
Three things fix this in practice:
- Measure empty-hit rate under your actual filters, not just aggregate recall, and run a max-selectivity test where you filter down to the smallest realistic tenant or repo and confirm results still return.
- Track filter selectivity distribution and shard fanout so you know which filters are pushing queries into disconnected pockets of the index.
- Push filters into the index itself through tenant-local collections or pre-materialized postings rather than bolting them on after the ANN search.
Pro Tip: If you support more than a handful of tenants or repositories, tenant-local collections cost more in memory and write isolation, but they eliminate the disconnected-island problem entirely. Query fanout across many small collections is a cheaper trade-off than silent empty results in one big one.
Which Metrics Actually Catch Silent Retrieval Failures?
Average recall is the metric everyone tracks and the one that hides the failures that matter most. A system with a high average recall@10 can still fail a significant fraction of queries for specific, high-value query patterns, like queries about a rarely-touched but critical part of the codebase, and the average number will never tell you that. A recent critique of vector database benchmarking proposes Robustness-δ@K specifically to address this: instead of averaging recall across all queries, it measures the fraction of queries that fall below an application-specific recall threshold. That tail fraction is the number that predicts user-visible failures, not the mean.
Beyond Robustness-δ@K, five signals belong on a dashboard, not buried in a weekly report:
vec_countversus expected document count, andvec_failedevent rate- Recall@k segmented by query type (head, torso, tail), not blended into one number
- Empty-hit rate specifically under active filters
- Cosine similarity distribution shifts over time, which flag embedding or data drift
- p99 query latency during ingestion or reindex windows, when index contention spikes
| Signal | Alert threshold guidance |
|---|---|
| Robustness-δ@K (tail recall) | Alert on any drop greater than a few points from your established baseline |
| vec_failed rate | Alert on repeated nonzero events, not just spikes |
| Empty-hit rate under filters | Alert when it rises above your historical norm for that tenant |
| p99 latency during ingestion | Alert on sustained latency above your normal serving SLO |
The fastest way to get real tail numbers is shadow testing: route roughly 1% of production queries to an exact, brute-force index running in parallel, then compute recall@10 against it, segmented by how frequently each query pattern occurs. Rare queries almost always show worse recall than common ones, and that gap is exactly what Robustness-δ@K is built to surface.
A Copy-Ready Runbook for Vector Retrieval Incidents
When a coding agent starts returning wrong or missing context, work through this in order.
- Triage. Check
vec_countagainst expected document count and inspectvec_failedevents. The kairix vector search runbook documents this exact sequence: confirm index files exist and aren’t corrupted, then test the embedding endpoint directly to rule out an upstream provider outage before touching the index itself. - Confirm the embedding pipeline is healthy. A surprising share of “retrieval quality” incidents are actually credential expirations or silent embedding job failures. Re-run the embedding pipeline on a small known batch and compare outputs to a cached baseline.
- Apply short-term fixes. Increase
ef_searchto widen the candidate pool, expand top-K retrieval and add a reranking step, or fall back to a BM25-plus-cross-encoder pipeline while you diagnose the vector path. Retrieving a wider candidate set (k=100) and reranking down is often more cost-effective than chasing marginal ANN recall gains through parameter tuning alone. - Roll out long-term controls. Version every embedding model change explicitly, run a dual-index strategy during any model or schema migration, schedule reindex windows instead of ad hoc reindexing, partition by tenant where access control matters, and keep tail recall and empty-hit rate on permanent dashboards.
- Cut over safely. Shadow the new index against the old one, define acceptance criteria in advance (recall@10 within your Robustness-δ@K threshold, latency within SLO), and keep the old index live until the new one clears that bar.
Pro Tip: Never delete the old index the moment the new one passes smoke tests. Keep it warm for at least one full traffic cycle, including whatever your slowest, rarest query pattern is, because that’s exactly where new indexes fail first.
For teams building this out from scratch, production-grade RAG pipeline engineering is a deep enough discipline that most organizations underestimate the operational surface area until an incident forces the issue.
When Bad Retrieval Leads to Unsafe Agent Actions
Retrieval failures become dangerous the moment an agent acts on what it retrieved without verification. A coding agent that pulls a stale or wrong document and treats it as ground truth can generate destructive commands, fabricate a policy that doesn’t exist, or expose data across a tenant boundary it should never have crossed.
Glitchive documents adjacent, illustrative cases worth knowing, without claiming either was caused by a vector database: a coding agent wiped a production database during an active code freeze, and a support chatbot invented a refund policy that a tribunal later held the airline liable for. Guardrails that matter regardless of root cause:
- Whitelist which commands an agent can execute without a human in the loop.
- Require dry-run mode for any state-changing action.
- Add a verification or reranking pass on retrieved content before it feeds a decision.
What This Failure-by-Industry View Gets Right About Coding Agents
The conventional advice on vector databases treats them like a database problem: pick the right index type, tune the parameters, move on. That framing misses what actually breaks in production. Every failure mode covered here, mismatched embeddings, bad chunking, stale indexes, broken filters, is really a data contract problem wearing infrastructure clothing. The Silicon Opera piece on premature vector database adoption makes a point most teams learn the hard way: write five real queries and their expected results before you write a single line of indexing code.
What’s overrated is chasing a marginally better recall number through parameter tuning. What’s underrated is the boring stuff: a runbook someone actually follows during an incident, a dashboard that tracks tail recall instead of averages, and a hard rule that no agent executes a destructive command without a human or a verification pass in between. Coding agents make this urgent because their mistakes execute. A wrong document to a chatbot produces a bad sentence. A wrong document to a coding agent can produce a wrong command.
Prioritize the runbook and the tail metric first. Everything else is tuning.
— GH
Sources
- Towards Robustness: A Critique of Current Vector Database Assessments
- Runbook — Vector search failure (kairix)
- You Added a Vector Database Before Knowing Why — Silicon Opera
- Why vector DB choice can kill your system - Architect’s Brief
FAQ
What Is the Most Common Vector Database Mistake?
Metric mismatch and unnormalized embeddings top the list because they produce plausible-looking but wrong results without throwing any error, making them the hardest failures to catch without a dedicated recall check.
How Do I Detect Stale Vector Indexes After a Model Upgrade?
Run a shadow index with the new embedding model alongside the old one, compare recall on the same smoke queries, and only cut over once the new index matches or beats the old one on segmented recall.
Why Does Average Recall Miss Real Retrieval Problems?
Average recall blends easy and hard queries into one number, so a system can score well overall while failing consistently on rare or tail query patterns; Robustness-δ@K measures that tail fraction directly.
How Do Filters Break Vector Search Results?
High-selectivity filters combined with post-filtering or naive pre-filtering can isolate matching vectors into disconnected pockets an ANN index never reaches, producing empty results even when matches exist.
Should Coding Agents Act Automatically on Retrieved Content?
No. State-changing actions should require a dry-run mode, an execution whitelist, or human approval, since retrieval failures can otherwise lead directly to unsafe or destructive agent behavior.