<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by LazyBeaver on Medium]]></title>
        <description><![CDATA[Stories by LazyBeaver on Medium]]></description>
        <link>https://medium.com/@marvellousinc7?source=rss-8e2e2505b147------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3Db2dPdUY5PzUsBGBQrfeA.jpeg</url>
            <title>Stories by LazyBeaver on Medium</title>
            <link>https://medium.com/@marvellousinc7?source=rss-8e2e2505b147------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 05:45:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marvellousinc7/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Better Prompt Won’t Fix Your Voice Agent’s Tool Calls]]></title>
            <link>https://medium.com/@marvellousinc7/a-better-prompt-wont-fix-your-voice-agent-s-tool-calls-9a4549ff857f?source=rss-8e2e2505b147------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a4549ff857f</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[ai-voice-agent]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[LazyBeaver]]></dc:creator>
            <pubDate>Fri, 20 Nov 2026 17:49:51 GMT</pubDate>
            <atom:updated>2026-11-20T17:49:51.000Z</atom:updated>
            <content:encoded><![CDATA[<p>#Voice Agent</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dgfIpVKjbiELPVnYrurd8Q.png" /></figure><p>Voice Agents Need Engineering inbetween the Prompts<br>A better prompt can help the model respond appropriately but not neccasarily correctly and efficiently when it comes to complex too calling</p><p>I’ve been working on a real-time voice agent for hotel booking calls and other related operations. This post focuses on our Gemini Live implementation, which uses Pipecat and WebRTC for the conversation and backend tools to interact with the hotel’s property management system, or PMS.</p><p>A lot of the work starts after the agent can already hold a decent conversation. A caller corrects their dates while availability is being fetched. A booking completes, but the agent says nothing. Someone interrupts a confirmation to change the reservation.</p><p>I’ve been working through these cases by making call state and tool execution more explicit.<br>Memory needs rules for forgetting<br>We started thinking about in-call memory through page tables and ended up with something much simpler: a structured object that belongs to one call.</p><p>It has four sections: stay, selection, guest, and confirmation. Alongside those, it stores numbered conversation turns, the latest tool results, and verified hotel data.</p><p>The agent uses remember_booking_details to record details supplied by the caller. It uses get_call_context to retrieve the structured state, transcript, and tool results. Recall currently returns the full stored transcript.</p><p>The important behavior is what happens when a detail changes.</p><p>Suppose the caller changes their checkout date from January 12 to January 13, extending a two-night stay to three nights. These simplified snapshots use synthetic data.</p><blockquote>Before the correction:<br>{<br> “stay”: {<br> “check_in”: “2027–01–10”,<br> “check_out”: “2027–01–12”<br> },<br> “selection”: {<br> “quote_id”: “quote-A”,<br> “stay_all_rooms”: 4249,<br> “currency”: “INR”<br> },<br> “guest”: {<br> “guest_name”: “Example Guest”<br> },<br> “confirmation”: {<br> “caller_confirmed”: true<br> }<br>}</blockquote><blockquote>After the correction:<br>{<br> “stay”: {<br> “check_in”: “2027–01–10”,<br> “check_out”: “2027–01–13”<br> },<br> “selection”: {},<br> “guest”: {<br> “guest_name”: “Example Guest”<br> },<br> “confirmation”: {}<br>}</blockquote><p>The guest’s details survive. The selected quote and confirmation do not, because they belonged to the earlier stay. Previously verified availability and room pricing are invalidated as well.</p><p>We verified these transitions with isolated unit tests against the memory class.</p><p>Overlapping availability requests have a separate safeguard. Each new lookup receives an incrementing identifier. If lookup A finishes after lookup B has started, A returns superseded and does not become the current verified result. An isolated unit test confirmed that ordering.</p><p>A request can finish successfully after its answer has become irrelevant.</p><p>Before placing a booking, the flow also rechecks the selected quote. It then checks whether the stored availability result changed while that verification was running. If it did, booking stops and the agent is asked to confirm the latest stay and room option.</p><p>These protections depend on the correction reaching the structured state or triggering a new lookup. Adding a sentence to the transcript alone does not update booking fields. Extracting the caller’s intended correction remains part of the agent’s job.<br>Give arithmetic a clear place to happen<br>We added a calculator for totals, averages, differences, and percentages. It parses an expression, permits numbers and basic arithmetic operators, and evaluates it using decimal arithmetic. Function calls and unsupported expressions are rejected; division by zero returns a request for corrected input.</p><p>Continuing the example, suppose the PMS returns a new three-night quote, quote-B, totalling ₹5,499. The previous two-night quote, quote-A, was ₹4,249. If the caller asks how much more the revised stay costs, the calculation is:<br>5499–4249 → 1250</p><p>These are synthetic amounts. Both totals represent supplied PMS quotes. The calculator computes the difference without assuming that the extra night costs the same as either previous night.</p><blockquote>We also checked:<br>0.1 + 0.2 → 0.3</blockquote><p>That checks a familiar numerical issue: ordinary binary floating-point arithmetic in Python produces 0.30000000000000004. Decimal arithmetic avoids that artifact for this calculation.</p><p>The tool still needs current inputs. If the caller has changed to three nights and the agent continues using the two-night quote as the current price, correct arithmetic will produce the wrong answer for the booking.<br>We tried rebuilding the session to change language<br>One implementation switched languages by disconnecting the model session and reconnecting with new language settings.</p><p>That required coordinating a spoken switching notice, suppressing output from the old session, retaining pending caller text, clearing the session-resumption handle, establishing the new connection, waiting for readiness, and replaying the pending request.</p><p>That is quite a lot of machinery for “let’s continue in Hindi.”</p><p>We later removed this path. The replacement keeps one multilingual Gemini session alive, allowing language selection to stay within the existing conversation. That removes the disconnect, readiness wait, and replay sequence from language switching.</p><p>The simplification reduces the number of transitions the application has to coordinate. We don’t have a measured latency improvement to report.</p><p>The experiment also illustrates the work hidden inside a session reset. Whether a reset is deliberate or caused by a failure, the application needs to account for pending speech, conversation context, and tool operations that may already have completed.<br>A tool result still has to become a response<br>We record separate events for a tool result becoming ready, being delivered to the model, and failing during delivery. That helps distinguish a backend operation completing from the model receiving its outcome.</p><p>The Gemini implementation also has a response watchdog. After a final tool result is delivered, it waits five seconds for model output. If none arrives, it waits until the caller has stopped speaking and the session is available, then prompts the model once to continue from the result already in context.</p><p>The instruction is specific: explain the outcome, retain known details, and do not call the function again.</p><p>If the model dosent say anything after that prompt, this watchdog has no second escalation step. It is a bounded recovery attempt.</p><p>It also monitors model output, not playback at the caller’s device. Generating a response does not establish that the caller heard it.<br>Three facts that can disagree<br>Consider this sequence. It is illustrative; place_booking is the actual voice tool name.<br>Event What the caller wants What the backend has done What the caller has heard<br>Agent calls place_booking Two nights Booking is in progress No success confirmation<br>Backend creates the reservation Two nights Two nights booked No success confirmation yet<br>Caller says, “Actually, make it three nights” Three nights Two nights booked The old confirmation may be queued or partly played<br>Agent handles the correction Three nights Existing reservation needs to be addressed Needs an accurate explanation of what happens next</p><p>The system has three facts to keep separate: what the caller wants, what the backend has done, and what the caller has heard.</p><p>Our booking tools continue through a conversational interruption: the caller talking over the agent does not cancel an in-flight booking operation. The booking can therefore finish while the caller is already asking for something different.</p><p>A stay correction clears confirmation, but it does not erase every record of that completed booking. The successful operation remains available through verified_hotel_operation and the latest place_booking result. When the PMS supplies a booking reference, it survives inside the result’s message. We verified that retention with isolated unit tests.</p><p>That preserves evidence that a booking exists. It still leaves us without a dedicated structured receipt containing the booking identifier and the details that were committed. The retained results are also latest-result slots, rather than a permanent history of completed operations.</p><p>The booking harness has another protection: an application-level idempotency key derived from the call, property, selected quote, and request. Matching concurrent requests share an in-flight task. Successful results are cached and returned to subsequent matching requests.</p><p>This prevents repeated execution of the same request within that harness. It does not recognize every pair of requests referring to the same intended reservation.</p><p>Changing two nights to three produces a different key. If the agent sends that correction through booking creation again, deduplication will not prevent a second reservation. The correction needs an amendment flow that addresses the booking already created.</p><p>The deduplication state also lives in memory. It does not provide a durable guarantee across server restarts or independent workers.</p><p>At the HTTP layer, booking writes are not automatically retried after a timeout. If creation cannot be verified, the voice flow asks the caller to check with the front desk before trying again. A missing response does not establish that the write failed.<br>What remains open<br>The implemented protections give us concrete behavior to inspect and test. They also leave several gaps:<br><em>- Changes after commit need an amendment flow, supported by a structured receipt that remains available when the caller revises their request.<br>- Deduplication needs to survive process restarts and work across workers.<br>- Playback accounting needs to establish how much audio was delivered before an interruption.<br>- The watchdog needs a defined fallback if its single continuation prompt produces no response.<br>We haven’t established a universal architecture for reliable voice agents. We have implemented specific protections and can identify the boundaries they cover.</em></p><p>For a booking call, the standard is practical: the caller’s latest request, the stored booking, and the spoken confirmation should agree. Keeping those three aligned throughout an interrupted conversation is where much of the engineering happens.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a4549ff857f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>