Voice agent RAG debugging means finding the first stage where the evidence disappears: the transcript, the search query, the retrieved chunks, the prompt, or the answer. Replaying the caller's words as text separates a speech error from a retrieval error. Each branch ends in a fix and a regression test, and rewriting the answer prompt is the last thing to try.
TL;DR: Take one wrong answer and trace it through five stages. Did the agent hear the question? Did it search, and for the right thing? Did the right chunk come back? Did that chunk reach the model? Did the answer use it? Stop at the first "no". Fix that stage, then save the call as a regression test. The tables below give the evidence to log, the metrics, the fix for each failure, and what each voice platform lets you change.
Basis for this runbook: Public sources only: the documentation of Retell, Vapi, ElevenLabs, and LiveKit, the Ragas, TruLens, and DeepEval metric definitions, published research on speech recognition errors and retrieval, and the 2026 OWASP Top 10 for LLM Applications, all checked on November 30, 2026. It reports no Hamming measurements.
Scope: Voice agents that answer callers from a knowledge base through retrieval. Latency, missed intents, and dashboards are in the general voice agent debugging guide. If your whole knowledge base fits in the prompt and you have no retrieval step, only the first and last stages apply to you. A speech-to-speech model has no transcript stage to inspect, so stage 1 changes for it.
Last Updated: November 2026
Related Guides
- Debugging Voice Agents: Real-Time Logs, Missed Intents and Error Dashboards - everything outside the knowledge path
- Voice Agent Hallucination Detection Guide - how to detect an unsupported answer before you debug it
- LLM09 Vector and Embedding Weaknesses in Voice Agents - the same layer seen as a security risk
- Voice Agent Troubleshooting - symptom-first triage for the whole call
How do you debug retrieval failures in a voice agent?
Trace one wrong answer through five stages and stop at the first one where the evidence is missing. A voice agent adds a stage that a text chatbot does not have. The question reaches retrieval as a transcript of speech, so the search can fail before the knowledge base is ever involved.
| Stage | Question to ask | Evidence that answers it |
|---|---|---|
| 1. Transcript | Did the agent hear what the caller said? | The audio beside the transcript for that turn |
| 2. Search query | Did it search, and for the right thing? | Whether a retrieval ran for the turn, and the exact query text it sent, after any rewriting |
| 3. Retrieved chunks | Did the right passage come back? | Chunk ids, scores, and source documents for the top results |
| 4. Prompt | Did that passage reach the model? | The context the model was given for that turn |
| 5. Answer | Did the answer use it? | The spoken answer beside the chunk it should rest on |
Work through it in this order:
- Pick one call with a wrong answer. Write down what the right answer is and which document holds it.
- Listen to the turn and read its transcript. If they differ in a word that matters, such as a product name, a number, or a negation, you are in stage 1.
- Check that a retrieval ran for the turn at all. Where retrieval is a tool the model decides to call, it may not have. Then find the query that was sent. If the platform rewrites the conversation into a search query, read the rewritten one.
- Look at what came back. Is the right chunk in the results? At what rank, and with what score?
- Check what the model saw. Platform settings such as Retell's similarity threshold and ElevenLabs's limits on chunks and document length decide what is passed on, so a chunk can be retrieved and still not reach the model.
- Compare the answer with the chunk. If the chunk was there and the answer contradicts it, the failure is in generation.
If the document that holds the answer does not exist, none of the five stages failed. The knowledge base has a gap, and the fix is to write the content.
What should you log for every knowledge answer?
Log one record per knowledge answer that ties what was heard to what was searched, what came back, and what was said. Without it, every investigation starts by reconstructing the call from separate logs.
{ "call_id": "c_8f2e", "turn": 7, "audio_ref": "recordings/c_8f2e.wav#t=41.2,44.0", "asr_transcript": "what's the fee for an outgoing wire", "asr_confidence": 0.91, "reference_transcript": null, "retrieval": { "triggered_by": "every_turn", "query_text": "outgoing wire transfer fee", "top_k": 3, "filters": { "tenant": "acme", "language": "en" }, "results": [ { "chunk_id": "fees-2026#12", "score": 0.74, "source": "fee-schedule-2026.pdf" }, { "chunk_id": "wires-howto#3", "score": 0.61, "source": "wire-transfers.md" } ], "kb_version": "2026-11-28", "latency_ms": 84 }, "context_sent_to_model": ["fees-2026#12"], "context_ref": "contexts/c_8f2e/turn-7.txt", "answer_text": "An outgoing wire is twenty-five dollars.", "expected_chunk_id": null}
The values are made up to show the shape. Here top_k is 3, two chunks cleared the threshold, and one of those reached the model. Four fields are easy to leave out, and each one answers a question the others cannot:
query_textis not the transcript. It is what retrieval was asked, after any rewriting.filtersrecords the tenant, language, or product scope that was applied. A wrong filter returns confident results from the wrong set.kb_versiontells you whether the index was stale at the time of the call.context_sent_to_modelcan be shorter thanresults. The difference is what was dropped. Chunk ids alone do not show a chunk that was cut short or reformatted on the way, socontext_refpoints to a stored copy of the exact text the model was given.
Two fields start empty. reference_transcript is what a person hears when they listen to the audio, and expected_chunk_id is the chunk that should have answered. Both are filled in when the call becomes a test case.
This record holds what a caller said, so treat it as call data. Redact personal data from the transcript, query, and answer fields before the record is stored, keep the audio and context pointers behind the same access controls as the recordings, and give the records a retention period. Our PII redaction guide for voice agent transcripts covers how.
If you trace with OpenTelemetry, its generative AI conventions define a retrieval span with a top-k attribute and opt-in attributes for the returned documents (id and score) and the query text. The conventions are marked Development, so the names can still change, and the query text attribute carries a warning about sensitive data. Our OpenTelemetry tracing guide for voice agents covers the rest of the call.
How do you tell a speech error from a retrieval error?
Replay the turn as text, twice, and compare the results. Send the transcript exactly as the recognizer produced it, then send the words the caller said, as written down by a person listening to the audio. If the correct chunk comes back for the caller's words and not for the transcript, the failure is in speech recognition. If it comes back for neither, the failure is in retrieval or in the content. If it comes back for both, retrieval can find the chunk, which is not the same as the call having found it. Go back to the original call's trace. If the call retrieved the chunk, the failure is further down, at stage 4 or 5. If the call ran no search or got different results, you are still at stage 2 or 3.
Send both through the same path the call used. On a platform that rewrites the conversation into a search query, a bare question sent straight to the index tests a query the live system never sent. Use a text or chat test of the same agent with the earlier turns included, so the rewrite runs as it did on the call.
This matters because the two errors look the same from the outside: the agent says something wrong. Published research shows the speech stage can be the cause. A study of open-domain question answering found that passage retrieval degrades on questions with speech recognition noise, and degrades more with natural noise than with synthetic noise (Sidiropoulos and colleagues, 2022). A 2024 paper on speech retrieval describes how recognition errors in a transcribe-then-retrieve pipeline can carry through into retrieval and generation. In that paper the documents are speech and the questions are text, the reverse of a phone call, so it shows the mechanism and not your case.
Names are where to look. In one 2026 study that used synthetic accents on multi-hop question sets, corrupted entities in the query accounted for 87 to 96% of the degraded cases on one of its datasets. That is a single paper under test conditions, so treat it as a pointer and not a rate for your calls. The pointer is useful: a misheard product name or plan name changes what retrieval looks for.
Word error rate will not tell you this on its own. WER is the number of inserted, substituted, and deleted words divided by the number of words in the correct transcript, as Jurafsky and Martin define it. It counts every word the same, so a transcript can score well and still have lost the one word the search depended on. Measure recognition on the terms your knowledge base is indexed by. Our ASR accuracy evaluation framework and the list of ASR failure modes in production go further on that.
How do you check that the right chunk was retrieved?
Label which chunk should answer each test question, then measure where that chunk lands in the results. A single call tells you what happened once. A labelled set tells you whether a change made retrieval better or worse.
| Metric | Definition | Use it for |
|---|---|---|
| Recall at k | The fraction of a question's relevant chunks that appear in the top k results | Whether the evidence is reachable at all with your top-k setting |
| Success at k | Whether at least one relevant chunk is in the top k | A simpler pass or fail per question, when one chunk is enough |
| Precision at k | The fraction of the top k results that are relevant | How much noise the model is given alongside the evidence |
| Reciprocal rank | One divided by the rank of the first relevant chunk. Its average over a set of questions is mean reciprocal rank | Whether the right chunk comes first, which matters when k is small |
| nDCG | Gain summed in ranked order with a discount for lower ranks, divided by the best possible ordering | Ranking quality when chunks have graded relevance |
The definitions follow the ir-measures documentation, the Stanford information retrieval book, and scikit-learn's nDCG reference. Be careful with the first two rows. Some guides use "Recall at k" to mean "at least one relevant result in the top k", which ir-measures calls Success at k. State which one a number means before comparing it with anyone else's.
For a voice agent, set k to what the platform retrieves on a call, not to a larger number that looks better. If the platform passes three chunks to the model, recall at ten describes a system your callers never use.
How do you check that the answer used the retrieved text?
Break the answer into claims and check each claim against the chunks the model was given. This is the measure Ragas calls faithfulness: the number of claims supported by the retrieved context divided by the total number of claims in the response.
Two more measures split the remaining cases. Ragas's context recall asks how many of the claims in a reference answer are supported by what was retrieved, so it needs a reference answer. TruLens groups three checks as the RAG triad: whether the context is relevant to the question, whether the response is grounded in the context, and whether the response addresses the question. DeepEval documents contextual recall, precision, and relevancy along the same lines.
Faithfulness has a blind spot. It checks the claims an answer makes, so an answer that leaves out the fact the caller asked for can still score perfectly. Pair it with a check that the expected fact is present.
Read them together:
- High context recall, low faithfulness. The evidence was there and the answer did not use it. This is the one case where the prompt or the model is the place to look.
- Low context recall, high faithfulness. The answer is true to what was retrieved, and what was retrieved was wrong or incomplete. Go back to stage 3.
- Both high, answer still wrong. The document itself is wrong or out of date, or the judge or the reference answer is.
These scores come from a model acting as judge, so they carry its errors. A judge reading a spoken answer also has to match forms such as "twenty-five dollars" against "$25" in the document, so spot-check its verdicts on numbers and dates. The authors of the original RAGAS paper reported that context relevance was the hardest of their measures to evaluate. TruLens's own documentation notes that passing all three checks supports the absence of hallucination only up to the limits of the knowledge base. Our hallucination detection guide covers scoring in production.
Which fix goes with which retrieval failure?
Match the fix to the first stage that failed, and write the regression test in the same change. Rewriting the answer prompt is the fix in one row of this table.
| Where the evidence disappears | What you see | Fix | Regression test |
|---|---|---|---|
| Transcript | The transcript differs from the audio in a key term | If your recognizer supports term hints or a custom vocabulary, add the term. Have the agent read unusual names back to confirm them | The same audio produces a transcript that contains the term |
| Search query: none | There is no retrieval record for the turn, on an agent whose other turns do have one | First rule out missing logging: a turn you know searched should show a record. If logging is sound, name the retrieval tool and when to use it in the system prompt, or switch to retrieval on every turn where the platform offers it | The turn produces a retrieval record |
| Search query | The transcript is right and the query is not: a rewrite dropped the detail, or a follow-up lost its subject | Fix the rewrite step, or give it more turns of the conversation to work from | The turn sequence produces a query that contains the detail |
| Retrieved chunks: not found | The right chunk is not in the top k for the caller's words | Add lexical search beside vector search and fuse the rankings. Rewrite the chunk so it stands alone. Re-chunk | Recall at k for that question on the labelled set |
| Retrieved chunks: ranked low | The right chunk is found below the cut | Add a reranker, or raise k if the latency allows | Reciprocal rank for that question |
| Retrieved chunks: wrong set | Results are confident and from the wrong tenant, language, or product | Fix the filter at query time | The query returns only chunks in the caller's scope |
| Retrieved chunks: stale | The right chunk is an old version | Re-index, and record the index version on every call | The answer matches the current document |
| Context | The chunk was retrieved and never reached the model | Check the similarity threshold, the context length limit, and the order chunks are added in | The chunk id appears in the context sent to the model |
| Answer | The chunk reached the model and the answer contradicts or ignores it | Now change the prompt, or the model | Faithfulness for that question, and a check that the expected fact is in the answer |
| Nothing failed | No document holds the answer | Write the content. Make the agent say it does not know | The agent declines or hands off when retrieval returns nothing relevant |
Three of the fixes have a primary source worth reading before you build them. One way to fuse a lexical ranking with a vector ranking is reciprocal rank fusion, which scores each document as the sum of one over a constant plus its rank in each list. The original paper fixed the constant at 60, and Elasticsearch's implementation uses the same default. A reranker is a second model that scores each returned document against the query and reorders them, as Cohere's Rerank documentation describes. For chunking, Pinecone's guidance is to start with fixed-size chunks and test several sizes against representative queries.
On making chunks stand alone, Anthropic published results from its own test sets for a method it calls contextual retrieval. It adds a short note to each chunk, written for that chunk, that places it in its source document before indexing. Anthropic reported the share of failed retrievals in the top 20 falling from 5.7% to 3.7% with contextual embeddings. Adding lexical search over the same contextualised chunks brought it to 2.9%, and reranking on top of both brought it to 1.9%. Those are one vendor's numbers on its own data, measured at a top 20 that is far above what a voice agent passes to the model. They show the direction, and you will have to measure your own.
Hybrid search, reranking, and a larger k add work to each turn while the caller waits. Measure the added time on calls before you ship them. Our voice AI latency guide covers where the time goes.
What do voice platforms let you change about retrieval?
Each platform decides when retrieval runs and exposes a different set of controls, so read the row for yours before assuming a fix is available. Every cell is from the platform's own documentation as of November 30, 2026. Latency figures are the vendor's statements about its own system.
| Platform | When retrieval runs | Settings its docs name | Query rewriting |
|---|---|---|---|
| Retell AI | Before every response, once a knowledge base is linked | Chunks to retrieve, 1 to 10 with a default of 3. Similarity threshold with a default of 0.6. Retell says the added latency should generally be under 100 ms | Yes. The recent conversation is condensed into a standalone query |
| Vapi, query tool | When the model calls the query tool. The docs say the system prompt must name the tool and when to use it | Knowledge bases with a name, a description, and files. No chunking or top-k setting on the pages we read | Not stated |
| Vapi, custom server | Vapi sends your server a request with the conversation | Everything, because your server does the retrieval. The timeout is up to 10 seconds, and Vapi says to aim for under about 50 ms | Yours to build |
| ElevenLabs Agents | Selectable: every turn, when the agent decides, or never (documents go in the prompt) | Embedding model, maximum vector distance, maximum retrieved chunks, and a maximum length for the retrieved documents. ElevenLabs says retrieval adds roughly 250 ms | Yes. The question is reformulated before it is embedded |
| LiveKit Agents | Your choice: a hook that runs when the user finishes a turn (for speech-to-text, LLM, text-to-speech pipelines), or a function tool the model decides to call | None built in. You write the lookup | Yours to build |
The "when retrieval runs" column is why stage 2 starts by asking whether a search happened. Where retrieval is a tool the model decides to call, the model may not call it. Vapi's documentation warns that a knowledge base description alone is not enough and that the system prompt has to tell the assistant when to use the tool. A turn with no retrieval record is the "Search query: none" row in the failure table, once you have confirmed that your logging captures retrievals at all.
What tools diagnose RAG knowledge failures in voice agents?
Three kinds of tool do, and each sees a different part of the call.
- The voice platform's own logs show the transcript and, on some platforms such as Retell, the retrieved chunks. That covers stages 1 and 3 for a single call.
- A tracing layer records the query, the returned chunk ids and scores, and the context sent to the model on every call. The OpenTelemetry conventions above are one vendor-neutral way to shape it, and our voice agent observability architecture guide lists what to trace across the stack.
- An evaluation library scores retrieval and grounding on a labelled set. Ragas, TruLens, and DeepEval each document the measures used in this runbook.
The evaluation libraries cited here score text, so they see a question as if it had been heard correctly. That is why the replay step in this runbook runs the transcript and the caller's real words as two separate inputs.
Hamming is our product. It tests and red-teams voice and chat agents, and it adds runtime security that monitors production calls and blocks bad behavior in real time. We left it out of the list because the steps above need only these three kinds of tool.
How do you turn a retrieval failure into a regression test?
Save the failing call as a case with its expected chunk and its expected answer, then run it at two levels: text into retrieval, and audio into the agent. The first is fast and isolates the index. The second is the only one that covers speech.
- Save the caller's words, the recognizer's transcript, and the audio for the turn.
- Record the chunk that should have answered it and the correct answer.
- Add a retrieval case: this query text returns that chunk id within the top k your platform uses.
- Add an end-to-end case: this audio, or a synthetic call that says the same words, produces an answer that states the correct fact.
- Add a no-answer case if the fix was to decline: this question gets a refusal or a handoff, and no invented answer.
- Run all three whenever the knowledge base, the chunking, the embedding model, the retrieval settings, the recognizer, or the prompt changes.
Keep the cases in files beside the agent's configuration, as in our tests-as-code template. The wider loop, from a failed call to a permanent test, is in the runbook for turning failed production calls into regression tests.
When is a retrieval failure a security problem?
It is a security problem when the chunk that came back was one the caller should not have had, or one somebody planted. A wrong fee quoted from an old document is a quality failure. A fee schedule read out from another customer's contract is a disclosure.
OWASP's 2026 list covers this layer as LLM09:2026 Vector and Embedding Weaknesses. Its mitigations include applying the tenant scope inside the index query, which is the control the "wrong set" row in the failure table depends on. One of the risks it names is poisoning at retrieval time, where content added to the index is written to be retrieved and to steer the answer. In a call log that looks like an ordinary wrong answer. If the planted text carries instructions, that is prompt injection, which our LLM01 prompt injection page covers.
The same evidence record serves both investigations. OWASP's mitigations for this item also include retrieval logs that hold the tenant scope, the query, the returned ids, and the scores. When a debugging session finds a chunk from the wrong scope, stop treating it as a relevance bug and follow the steps in our LLM09 page for voice agents.
Where this runbook stops
This runbook finds which stage failed for the calls you examine. It does not tell you how often each stage fails across all your calls, and it cannot find a wrong answer nobody flagged. For that you need the scoring in production that the hallucination detection guide describes. The judge-based measures here are estimates from a model, and a passing regression test covers the questions in your set against the configuration you ran.
Start with one call. Pull a recent wrong answer, fill in the evidence record by hand, and find the first stage where the evidence is missing. If you cannot fill in a field, that missing field is the first thing to fix.