### The Failure Mode: An Ungrounded Voice Agent Invents Your Menu
Connect a large language model straight to a phone line and ask it to take orders, and it will sound convincing right up until it does not. Without grounding, the model answers from what it has seen in training, not from your menu. It quotes a price that sounds plausible. It agrees that yes, you do have a gluten-free base, because most pizza places do. It confirms a large pepperoni at a price your kitchen has never charged, and the first person to discover the mistake is the customer at the counter, or the driver at the door.
This failure is worse on voice than on chat. In a chat window, the customer can scroll, compare, and spot a wrong price before paying. On a phone call there is no screen. The caller hears a confident voice, trusts what it says, and only finds out later. Every invented item becomes a refund, a remake, or a lost regular.
Retrieval-Augmented Generation (RAG) fixes this at the architecture level. Instead of asking the model what your menu contains, the system retrieves the relevant menu records first and requires the model to answer only from those records. The model still handles the conversation. It just no longer gets to decide what you sell or what it costs. The sections below walk through how to build that, step by step, on the same Vapi, Twilio and Deepgram stack covered in my sub-600ms voice agent architecture guide.
Step 1: One Source of Truth for the Menu
Everything starts with structured data. Your menu or catalog needs to exist as one record per item, with the fields the agent is allowed to talk about:
1. Item name and aliases: "Margherita", plus the ways callers actually say it. 2. Price: one authoritative number per size or variant, stored as data, never written into a prompt. 3. Variants and modifiers: sizes, bases, extras, each with its own price delta. 4. Availability: in stock, sold out, or limited, with a timestamp. 5. Constraints: allergens, dietary flags, minimum order rules, delivery zones.
If this data currently lives in a PDF, a printed menu, or someone's head, that is the first project. RAG cannot ground an agent in data that does not exist in machine-readable form. For most restaurants and takeaways this means exporting the POS catalog or building a simple structured menu file and treating it as the single source that both the website and the voice agent read from.
Step 2: Chunk by Item, Not by Page
Standard RAG advice says to split documents into chunks of a few hundred words. For a menu, that is exactly wrong. If a chunk boundary falls between an item name and its price, retrieval can return the name without the price, and the model will fill the gap with a guess.
Chunk by item instead. One chunk per sellable item, containing the name, description, price, variants, modifiers and availability in a single unit. A 120-item menu becomes 120 chunks, each self-contained. When the retriever returns the "Gluten-Free Margherita" chunk, the price and the base options arrive in the same breath, so the model never has to assemble facts from two different places. The same item-level approach is what makes the hybrid search design in my production RAG architecture guide reliable for catalogs in general.
Step 3: Hybrid Retrieval for Names and Fuzzy Descriptions
Callers describe food in two ways. Sometimes they use the exact name: "one large pepperoni". Sometimes they describe it: "the spicy chicken one with the peppers". Pure keyword search nails the first and misses the second. Pure vector search handles the second and can fumble exact names, sizes and codes.
Hybrid retrieval runs both and merges the results:
1. Keyword search over item names and aliases catches exact matches and near-exact spellings. 2. Vector search over item descriptions catches meaning: spicy, vegetarian, kid-friendly, low-calorie. 3. A merge and rerank step combines both lists and returns the top few items to the model.
Keep the result set small. For voice, the top 3 to 5 items are enough; the agent can ask a clarifying question if the caller meant a different one. Returning twenty chunks slows the response and gives the model more room to mix facts between items.
Step 4: Grounding Rules: Quote Only What Was Retrieved
Retrieval alone does not stop hallucination. The system prompt and the tool design have to enforce the boundary:
1. Prices come from records, never from the model. The agent reads the price field of the retrieved item. If two sizes exist, it asks which size instead of picking one silently. 2. No result means no answer. If retrieval returns nothing relevant, the agent says it cannot find that item and offers the closest real alternatives or a human. It never invents a "chef's special" to be helpful. 3. Availability is part of the answer. A sold-out item is either filtered out before retrieval or returned with its sold-out flag, and the agent says so plainly. 4. Totals are calculated, not estimated. The order total is computed by code from item prices and modifier deltas, then spoken back. The model does not do arithmetic in its head.
This is the same zero-hallucination discipline described in the production RAG guide: the model generates language, the system supplies facts.
Step 5: Structured Orders with Read-Back Confirmation
Taking the order is a tool call, not a paragraph of text. As the conversation progresses, the agent builds a structured order object: items, variants, modifiers, quantities, name, phone number, address or pickup time. Each addition is validated against the retrieved records before it enters the object.
Before anything is submitted, the agent reads the order back: items, sizes, extras, and the computed total, and waits for a clear yes. Only then does the order go to the POS, the kitchen printer, or your ordering system through a webhook or function call. If the caller changes something during read-back, the object updates and the total is recalculated. This read-back step catches the most common voice errors: misheard sizes, wrong quantities, and items the caller mentioned but did not mean to order. The tool-calling pattern itself is covered in detail in the MCP-enabled voice telephony architecture post.
Step 6: Keep Availability in Sync
A grounded agent with a stale index still sells food you cannot make. Availability has to flow from the source of truth into the index on a schedule that matches how fast your kitchen changes:
1. Sold-out items are flagged or removed from the index as soon as the POS marks them out. A few minutes of lag is the difference between a smooth call and an apology. 2. Price changes update the item record, and the chunk is re-embedded. Because chunks are per item, one price change means one small update, not a full re-index. 3. Daily specials get their own records with start and end times, so the agent offers them only while they are live.
The rule is simple: if it is not in the index, the agent cannot sell it, and if it leaves the index, the agent stops selling it.
Fitting Retrieval Inside the Voice Latency Budget
Voice has a hard budget. Callers notice silence, and every extra 100ms of thinking time makes the agent feel broken. Retrieval has to earn its place inside that budget:
1. Keep the index small and hot. A menu index is tiny compared to a document corpus. A few hundred item chunks can live in memory or in a fast vector store close to the voice service. 2. Precompute embeddings at ingestion time. Nothing gets embedded during a call except the caller's short query. 3. Cache the menu. Most calls ask about the same popular items. Cached retrieval results for common queries remove the lookup from the critical path. 4. Run retrieval in parallel with transcription. The moment Deepgram returns a stable partial transcript, the query can start; by the time the caller finishes the sentence, the items are already back.
Done this way, retrieval adds tens of milliseconds, not seconds. The full end-to-end budget breakdown, from SIP trunk to text-to-speech, is in the sub-600ms voice agent guide.
Worked Example: A Gluten-Free Pizza Order, End to End
A caller says: "Hi, do you have a gluten-free pizza, and how much is it?"
1. Transcribe: Deepgram streams the audio and returns the text while the caller is still speaking. 2. Retrieve: hybrid search runs "gluten-free pizza" against the item index. Keyword search matches the alias "gluten free base"; vector search matches items flagged with the gluten-free dietary attribute. The top results are the Gluten-Free Margherita and Gluten-Free Veggie, each with sizes and prices attached. 3. Ground: the agent answers from those two records only. It names both options with their real prices and asks which one the caller wants. It does not mention any other pizza, because nothing else was retrieved. 4. Confirm: the caller picks the Margherita, medium. The agent adds it to the structured order, computes the total in code, and reads it back: item, size, base, total. 5. Place: the caller says yes. The order object is sent to the ordering system, and the agent confirms the pickup time returned by that system.
At no point did the model decide what exists or what it costs. It retrieved, it read, it confirmed.
Failure Handling: No Match, Ambiguity, and Human Handoff
Production systems are judged by their bad moments, not their good ones. Four cases cover most of what goes wrong:
1. No match: the caller asks for something you do not sell. The agent says so, offers the closest retrieved alternatives if any exist, and offers a human if the caller insists. It never agrees that the item exists. 2. Ambiguous match: two items fit the description. The agent asks one short clarifying question with the real options named, instead of guessing. 3. Caller changes their mind mid-order: the structured order object is edited, totals are recomputed, and the read-back runs again before submission. Nothing is final until the last read-back is confirmed. 4. Human handoff: allergies with medical risk, complaints, large catering orders, or a caller who simply wants a person. The agent transfers with the order summary so far, so the caller does not repeat themselves.
If you are planning an ordering agent and want the grounding designed in from day one rather than patched in after the first wrong order, the AI voice agents service covers this architecture end to end, from menu ingestion to the live phone line.
