<?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 Shariful Islam Shohag on Medium]]></title>
        <description><![CDATA[Stories by Shariful Islam Shohag on Medium]]></description>
        <link>https://medium.com/@shohagislam.csm?source=rss-4949925d0c9c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*LrJrECbrQQDpCbJ8</url>
            <title>Stories by Shariful Islam Shohag on Medium</title>
            <link>https://medium.com/@shohagislam.csm?source=rss-4949925d0c9c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 13:59:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shohagislam.csm/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[I measured every stage of my voice pipeline. I had been wrong about my own system.]]></title>
            <link>https://medium.com/@shohagislam.csm/i-measured-every-stage-of-my-voice-pipeline-i-had-been-wrong-about-my-own-system-199e507a9857?source=rss-4949925d0c9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/199e507a9857</guid>
            <dc:creator><![CDATA[Shariful Islam Shohag]]></dc:creator>
            <pubDate>Tue, 22 Sep 2026 07:04:30 GMT</pubDate>
            <atom:updated>2026-09-22T07:04:30.155Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Part 3 of building an AI voice call center with .NET 9 — in public, including what&#39;s broken.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3GWeY8XrAoTpZ2fuby5cmg.png" /></figure><p>For weeks, I told people that the CPU was my problem.</p><p>It seemed like a reasonable explanation. The server has no GPU. Speech recognition runs on the CPU. The replies were slow. So the story seemed obvious.</p><p>I said it during conversations. I wrote it in planning notes. I also made decisions based on it.</p><p>Then I added proper measurements to the pipeline and checked the logs. That was when I discovered something important: the speech-to-text response time had never actually been recorded.</p><p>I had been making decisions based on a number that I did not have.</p><p>This article explains what I found after I finally measured the system properly.</p><h3>1. The problem</h3><p>One conversational turn — from the moment the caller finished speaking until the system replied — was taking between 30 and 120 seconds.</p><p>This was not just “slightly slow.” It was not a small performance problem. A caller could have hung up four times during that delay.</p><p>The pipeline used batch processing, and it worked like this:</p><p>Record the caller’s full speech into a WAV file, upload it to object storage, write an event to the database, wait for a worker to pick it up, download the WAV file, transcribe it, decide on a reply, generate the complete reply as another WAV file, upload that file, and finally play it back to the caller.</p><p>There were nine stages.</p><p>Any one of them could have been the problem. I had a strong opinion about which stage was responsible, but I had no evidence.</p><h3>2. Why “it’s the CPU” is not an answer</h3><p>“It’s the CPU” sounds like a conclusion, but it is only a hypothesis.</p><p>It is not useful enough to take action because it does not explain <em>which</em> CPU work is slow, <em>how much</em> time it takes, or whether one of the other eight stages is even slower.</p><p>There were at least five possible explanations. Each one required a completely different solution.</p><p><strong>Model inference</strong></p><p>Use a smaller model, quantisation, or a different runtime.</p><p><strong>HTTP between services</strong></p><p>Use batching or remove the service boundary.</p><p><strong>Object storage I/O</strong></p><p>Use streaming instead of saving and downloading files.</p><p><strong>The queue</strong></p><p>Add more workers or remove the queue from the critical path.</p><p><strong>Model loading</strong></p><p>Keep the models warm.</p><p>Choosing one of these solutions without measuring first is how you spend two weeks optimising something that was never part of the real problem.</p><p>So before writing any optimisation code, I added timing measurements to every stage of the existing pipeline. I left everything else unchanged.</p><h3>3. What I instrumented</h3><p>I added a named timer to every stage.</p><p>Each timer records:</p><ul><li>The elapsed time in milliseconds</li><li>The turn it belongs to</li><li>The number of calls running at that moment</li></ul><p>Here is one example:</p><pre>using (var _ = _timings.Measure(&quot;stt_inference_batch&quot;, turnId))<br>{<br>    transcript = await _stt.TranscribeAsync(audio, ct);<br>}</pre><p>The timer names are more important than they may seem.</p><p>stt_http_batch measures the complete call to the speech service.</p><p>stt_inference_batch measures only the model call inside that service.</p><p>If those two times are almost the same, then the network and serialisation between the services cost almost nothing. It means the model itself is expensive.</p><p>If the two numbers are very different, then the problem is somewhere in the communication between the services.</p><p>One extra timer can confirm or reject an entire explanation.</p><p>I also created a repeatable audio test. It sends the same recording through the same pipeline every time. This makes it possible to compare two different test runs properly.</p><h3>4. The numbers</h3><p>I collected the following measurements from 32 real calls on the production VPS. The server used only the CPU and had no GPU.</p><p><strong>Speech-to-text (HTTP)</strong><br>p50: 11,192 ms<br>p95: 19,730 ms<br>Samples: 32</p><p><strong>Speech-to-text (inference only)</strong><br>p50: 11,187 ms<br>p95: —<br>Samples: 32</p><p><strong>LLM reply</strong><br>p50: 4,557 ms<br>p95: 7,186 ms<br>Samples: —</p><p><strong>Text-to-speech</strong><br>p50: 890 ms<br>p95: —<br>Samples: —</p><p><strong>Response upload</strong><br>p50: 14.8 ms<br>p95: —<br>Samples: —</p><p><strong>Recording download</strong><br>p50: 4.5 ms<br>p95: —<br>Samples: —</p><p><strong>Worker queue</strong><br>p50: 16,541 ms<br>p95: 29,447 ms<br>Samples: 777</p><p><em>Per-stage latency</em></p><p>Three things became clear immediately.</p><h3>Storage I/O is basically free</h3><p>Downloading the recording took 4.5 ms. Uploading the response took 14.8 ms.</p><p>I had seriously considered removing the object-storage round trip from the critical path.</p><p>That change would have saved only nineteen milliseconds from a process that was taking around thirty-five thousand milliseconds.</p><h3>The speech model really is expensive — and now I can prove it</h3><p>stt_inference_batch took 11,187 ms.</p><p>stt_http_batch took 11,192 ms.</p><p>The difference was only 5 ms.</p><p>This means the HTTP call, serialisation, and service boundary added almost no meaningful delay. The model itself was responsible for almost all of the speech-to-text time.</p><p>My original hypothesis was correct.</p><p>But now it was supported by a real measurement instead of a story.</p><h3>The biggest number in the table was a lie</h3><p>The worker queue showed a p50 time of 16,541 ms across 777 samples.</p><p>That was higher than the speech-recognition time.</p><p>But it was not measuring the real waiting time for new work.</p><p>The metric was measuring the age of old turns that had been left in a backlog after earlier failures. It was not measuring how long a new turn waited in the queue.</p><p>After I cleared the old backlog and separated the metric correctly, the real values were:</p><p>queue_wait: 0.05 ms</p><p>poll_cycle: 44 ms</p><p>The metric was measuring the wrong thing. Because of that, it pointed to the wrong bottleneck more loudly than the real bottleneck.</p><h3>5. The number that actually explains it</h3><p>Milliseconds are not the best unit for understanding speech-recognition performance.</p><p>The more useful measurement is the <strong>real-time factor</strong>, or <strong>RTF</strong>.</p><p>RTF is calculated by dividing the model’s inference time by the duration of the audio.</p><p>Here are the measurements from one instrumented turn:</p><ul><li>Audio captured: 5,220 ms</li><li>Speech after voice-activity detection: 4,340 ms</li><li>Inference time: 12,410 ms</li><li><strong>RTF: 2.38</strong></li></ul><p>The machine needs 2.38 seconds of processing time for every one second of caller speech.</p><p>The system is not simply slow. It is <em>falling behind</em> permanently, and the delay grows with every word the caller speaks.</p><p>Queue tuning cannot fix that. Streaming cannot fix that.</p><p>A system with an RTF above 1.0 cannot keep up with a live conversation. A system that needs to feel natural must have an RTF far below 1.0.</p><p>I then tested the model by itself.</p><p>I stopped the telephony worker. I stopped the LLM. Nothing else was running on the server.</p><p>For this test, I used a <em>larger</em> model with the following settings:</p><p>small, int8, 4 threads, beam 3, Bengali</p><p>The results were:</p><pre>7.98 s · 8.00 s · 7.25 s   on 7.74 s of audio   →   RTF ≈ 1.48</pre><p>That was better.</p><p>But the RTF was still above 1.0, even when the machine was otherwise completely idle.</p><p>That is the real finding from this entire experiment:</p><p><strong>This hardware cannot perform conversational speech recognition on the CPU with any model size that I can use.</strong></p><p>Compared with that problem, almost everything else in the table is just rounding error.</p><p>For completeness, the same turn also showed an LLM response time of 18,578 ms and a total time of 35,078 ms.</p><p>However, that run included a cold text-to-speech model load of 2,247 ms. When the model was warm, the same load took roughly 0.1 ms.</p><p>Cold starts are a different problem. They are cheap and easy to fix. They should also be measured separately so they do not affect the more important measurement.</p><h3>6. Three gaps the instrumentation itself revealed</h3><p>Adding the timers taught me as much about my observability as it taught me about performance.</p><h3>The concurrency field was null everywhere</h3><p>Every timing record had a field for the number of calls currently running.</p><p>But nothing in the system was filling in that field.</p><p>This meant that every measurement was difficult to understand correctly.</p><p>A 12-second inference while the server is handling several calls is very different from a 12-second inference while the server is idle.</p><p>I could not tell which situation had produced each measurement.</p><h3>Nothing measured what the caller actually experienced</h3><p>Every stage ended when the telephony system acknowledged the audio.</p><p>But an acknowledgement only means that the system has agreed to play the audio. It does not mean that the caller has started hearing it.</p><p>The most important number for the whole project is:</p><p><em>How long does the caller wait before hearing a reply?</em></p><p>There was no measurement for that number.</p><p>There still is not.</p><p>That is the next thing I am building.</p><h3>Speech records did not include the audio duration</h3><p>Without the audio duration, I could not calculate RTF.</p><p>RTF was the number that finally explained the real performance problem, but it was impossible to calculate from my first set of measurements.</p><p>I had to add the audio-duration field and run the test again.</p><h3>7. What this cost, and what’s next</h3><p>The measurement work took about two days.</p><p>It produced no improvement that a user could see.</p><p>It is difficult to justify that kind of work while you are doing it. But it has been the highest-return work I have done on this project.</p><p>It stopped me from spending two weeks on an optimisation that would not have solved the real problem.</p><p>It also replaced an opinion that I had been repeating with a number that I can now defend.</p><p>If I did this again, I would measure concurrency and input size <em>before</em> adding any duration timer.</p><p>A duration without the system load and the input length is not a complete measurement.</p><p>It is only an anecdote with a unit attached.</p><p>The measurements changed my plans in several ways:</p><ul><li>The real-time gateway plan still stands, but latency is now a speech-provider problem, not an architecture problem.</li><li>The queue is not part of the critical path, and it never was.</li><li>Cold model loading will be fixed separately because it is a cheap problem to solve.</li><li>This hardware cannot support a conversational demo using local CPU speech recognition.</li></ul><p>But there is a stranger problem underneath all these numbers, and I skipped over it earlier.</p><p>During the isolated test — the good one with an RTF of 1.44 — the system transcribed clear Bengali speech into Devanagari characters.</p><p>The words were not simply incorrect.</p><p>The system used the wrong writing system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*fymt0D460ZIggQVvqNndsQ.png" /></figure><p><em>Part 2: A voice bot talks. A workflow agent has to be right.</em></p><p><em>Part 4: Why Bengali speech recognition breaks on 8 kHz telephony audio — 16 October.</em></p><p><em>The production repository is private. Measurements, diagrams and minimal examples from this series are published separately.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=199e507a9857" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A voice bot talks. A workflow agent has to be right.]]></title>
            <link>https://medium.com/@shohagislam.csm/a-voice-bot-talks-a-workflow-agent-has-to-be-right-005b6d53ffe4?source=rss-4949925d0c9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/005b6d53ffe4</guid>
            <dc:creator><![CDATA[Shariful Islam Shohag]]></dc:creator>
            <pubDate>Wed, 16 Sep 2026 07:38:08 GMT</pubDate>
            <atom:updated>2026-09-16T07:38:08.884Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Part 2 of building an AI voice call center with .NET 9 — in public, including what’s broken.</em></p><p>The first time my system said “Booked!” out loud, nothing had been written to the database.</p><p>It was not a normal bug. The transcript looked reasonable, the model’s reply sounded good, and the audio played correctly. Every part did what it was supposed to do. The only thing missing was the database row.</p><p>That is what this article is about. A voice bot’s job ends when the sentence sounds right. An appointment agent’s job ends when exactly one row exists, it is the correct row, and the caller hears a confirmation that matches it. These are not the same goal, and most of the popular voice-AI tools are not designed for the second one.</p><h3>1. The problem</h3><p>I am building an appointment-focused voice call center. A caller phones in, explains what they want, and by the end of the call there should be a booking — or a clear, honest failure.</p><p>Everything about that sentence is harder than it looks:</p><ul><li>The caller speaks over a phone line, at 8 kHz, often in a noisy room.</li><li>The transcript is a guess, with a confidence score that is also a guess.</li><li>“Tuesday” means different dates depending on when the call happens.</li><li>The caller changes their mind halfway through the sentence.</li><li>The network can drop a response <em>after</em> the work was already done.</li></ul><p>A system that only needs to give a possible reply can ignore these problems. A system that writes to a database cannot.</p><h3>2. Why the obvious solution fails</h3><p>The obvious solution in 2026 is tool calling: describe your booking function to the model, let it fill in the arguments, and execute what comes back.</p><p>It looks great in a demo. It fails in three specific ways that only become clear when real data is involved.</p><p><strong>The model is confident about things it has no way to know.</strong> A transcript that returned Devanagari characters for Bengali speech can still produce a properly formed function call. The arguments look fine. They have the correct types. They are still wrong.</p><p><strong>A retry looks the same as a new request.</strong> When a tool call times out, the model does the normal thing and tries again. But a timeout does not mean the work failed — it means you do not know whether it failed. If the first attempt already wrote a row and the second attempt writes another one, the caller now has two appointments and no idea why.</p><p><strong>Correction has no natural place.</strong> Callers say “no, not Friday — Saturday” all the time. A model asked to handle this using conversation history will sometimes go back one step, sometimes start over, and sometimes quietly keep both dates in its context and choose one. There is no state to go back to, because there was never any state.</p><p>None of these are failures of the model. They are failures of the boundary — of putting something uncertain directly on top of something that needs to be exact.</p><h3>3. The decision: proposals and commands</h3><p>The rule I settled on is simple enough to say in one line:</p><blockquote><strong><em>The model produces a proposal. It never produces a command.</em></strong></blockquote><p>A <strong>proposal</strong> is what the model thinks it heard. It is a simple bag of strings, and the type says so:</p><pre>public sealed record BookingProposal(<br>    string? ServiceCode,   // what the model matched against the service list<br>    string? Date,          // &quot;2026-09-29&quot;, as heard<br>    string? Time,          // &quot;14:30&quot;, as heard<br>    string? Digits,        // phone number, unnormalised<br>    double  Confidence);   // the STT layer&#39;s own estimate</pre><p>Everything is nullable. Everything is a string. Nothing in the type system says that any of it is true.</p><p>A <strong>command</strong> is a separate type that represents work the system has agreed to do. Its constructor is private, so no caller anywhere can create one directly:</p><pre>public sealed record BookAppointment<br>{<br>    public Guid             ServiceId    { get; }<br>    public DateTimeOffset   SlotStartUtc { get; }<br>    public string           Phone        { get; }</pre><pre>    private BookAppointment(Guid serviceId, DateTimeOffset slotStartUtc, string phone)<br>        =&gt; (ServiceId, SlotStartUtc, Phone) = (serviceId, slotStartUtc, phone);</pre><pre>    public static Result&lt;BookAppointment&gt; TryCreate(<br>        BookingProposal p, IClock clock, IServiceCatalog catalog)<br>    {<br>        if (p.Confidence &lt; 0.75)<br>            return Result.NeedsConfirmation(&quot;low transcript confidence&quot;);</pre><pre>        if (!catalog.TryResolve(p.ServiceCode, out var serviceId))<br>            return Result.Reject(&quot;unknown service&quot;);</pre><pre>        if (!Slot.TryParseLocal(p.Date, p.Time, out var slotUtc))<br>            return Result.Reject(&quot;unparseable date or time&quot;);</pre><pre>        if (slotUtc &lt;= clock.UtcNow)<br>            return Result.Reject(&quot;slot is in the past&quot;);</pre><pre>        if (!Phone.TryNormalize(p.Digits, out var phone))<br>            return Result.Reject(&quot;invalid phone number&quot;);</pre><pre>        return Result.Ok(new BookAppointment(serviceId, slotUtc, phone));<br>    }<br>}</pre><p><em>(This is a minimal example written for publication, not my implementation. It skips persistence, tenancy and observability on purpose.)</em></p><p>The shape is what matters, not the specific checks:</p><ul><li><strong>If validation fails, no command exists.</strong> There is no half-valid object that can accidentally be passed along, no IsValid flag someone forgets to check, and no invalid state to handle at the call site. It cannot be created.</li><li><strong>Three outcomes, not two.</strong> Reject is a hard no. NeedsConfirmation is different and important — it means the input might be right but is not trusted enough to act on, so the conversation asks again instead of guessing. Most transcript problems end up here.</li><li><strong>Time resolves once, at the boundary.</strong> Slot.TryParseLocal turns &quot;Tuesday, 2:30&quot; into an exact time in UTC using the clock passed into the call. After that point, nothing downstream needs to think about relative dates anymore.</li></ul><p>The model’s output is an input to this function. It is never the function’s authority.</p><h3>4. What this costs</h3><p>It is worth being honest that this is not free.</p><p><strong>It is more code.</strong> Tool calling is one function signature. This is a proposal type, a command type, a result type, a validator, and the code that connects them.</p><p><strong>It is less flexible.</strong> The model cannot create a booking shape that I did not plan for. For an appointment workflow that is the whole point, but if you are building something open-ended, this design can get in your way.</p><p><strong>It moves the hard problem, it does not remove it.</strong> Deciding <em>what the caller meant</em> is still genuinely hard, and it still happens in the uncertain part of the system. What this gives me is that being wrong about the caller’s meaning causes the system to ask again instead of changing the database.</p><p><strong>The confidence threshold is a guess.</strong> 0.75 is not based on a strong rule. It is what has worked acceptably so far, and it will change once I have real accuracy measurements across different callers.</p><h3>5. Where the rest of the safety lives</h3><p>Validation is only the first of four layers, and it is the weakest one. The others show up in later parts of this series:</p><p>LayerProtects againstPartCommand validationnonsense input reaching the write paththis oneConversation state machineimprovisation, lost corrections, infinite loops05Database constraintstwo callers taking the same slot06Idempotency keysa retry becoming a second booking07</p><p>The ordering is deliberate, and it took me a while to accept it: <strong>application validation improves the caller’s experience, but only database constraints protect correctness.</strong> A validator that checks whether a slot is free is useful and can never be enough, because two callers can pass that check within the same millisecond. Part 06 is about learning that the hard way.</p><h3>6. The stack, briefly</h3><p>Since people always ask: .NET 9 with EF Core, SQL Server, Asterisk for telephony, RabbitMQ and Redis, Angular for the admin application, Docker Compose to run it. faster-whisper and Piper for speech, for now.</p><p>These are not interesting choices, and I do not think they should be. The interesting decision was never which pieces to use — it was where the trust boundary sits between them.</p><h3>7. What’s next</h3><p>Part 03 is the one I have been waiting to write. I added tracking to every stage of the voice pipeline and measured real calls, and the result was different from what I had been confidently telling people about my own system for weeks.</p><p>The headline number is 35,078 milliseconds for a single turn. The interesting part is where it goes.</p><p><em>Part 1: [What I’m building — and what’s still broken]</em><br><em>Part 3: Where 35 seconds of latency actually goes.</em></p><p><em>The production repository is private. Diagrams, measurements and minimal examples from this series are published separately.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=005b6d53ffe4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I’m Building an AI Voice Call Center — and Sharing What Breaks]]></title>
            <link>https://medium.com/@shohagislam.csm/im-building-an-ai-voice-call-center-and-sharing-what-breaks-0b7b1baea8e4?source=rss-4949925d0c9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b7b1baea8e4</guid>
            <category><![CDATA[asterisk]]></category>
            <category><![CDATA[pbx-system]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[ai-voice-agent]]></category>
            <dc:creator><![CDATA[Shariful Islam Shohag]]></dc:creator>
            <pubDate>Sun, 13 Sep 2026 14:58:47 GMT</pubDate>
            <atom:updated>2026-09-13T14:58:47.546Z</atom:updated>
            <content:encoded><![CDATA[<p><em>An honest engineering journey from generating voice replies to safely completing real business workflows.</em></p><p>My AI voice agent once took 35 seconds to answer a caller.</p><p>In another test, it heard clear Bengali speech and decided the language was English. In a third run, a different model transcribed that same Bengali audio into Devanagari script and returned this:</p><blockquote><em>अनी अगामिका वाखार वाश्टाई अपन्में लिखचाई</em></blockquote><p>None of this makes for a polished product demo. But all of it taught me the same lesson: the real engineering work starts <em>after</em> a voice bot can produce its first convincing reply.</p><p>I am building an appointment-focused AI voice call center. The business platform is .NET and SQL Server, and the realtime voice layer is being built in Python alongside it. The goal is not a system that can simply listen and respond. It has to understand a caller, collect missing information, check availability, and then safely book, correct, cancel, or reschedule an appointment.</p><p>That word — <em>safely</em> — is what this whole series is about.</p><p>And if you are building anything that lets a language model trigger a real write to your database, you have the same problem I do, even if your product never touches a phone line.</p><h3>A convincing reply is not a completed workflow</h3><p>Most voice AI demos focus on the conversation layer:</p><ul><li>the caller speaks</li><li>speech-to-text produces a transcript</li><li>a language model generates a response</li><li>text-to-speech plays that response back</li></ul><p>If the response sounds natural, the demo looks successful. An appointment workflow has a stricter definition of success, because real calls are messy. A caller may change the requested date after hearing it repeated back. Two callers may try to book the same slot at almost the same moment. A network timeout may cause the same booking operation to be retried. A transcript may contain the wrong phone number while still reading as a perfectly correct sentence.</p><p>In these situations, sounding confident is not enough. The system has to guarantee that exactly one correct booking exists, that invalid input never reaches the write path, that retries do not create duplicate actions, and that the confirmation spoken to the caller matches what was actually stored.</p><p>That requires a clear boundary between language interpretation and business authority.</p><h3>The boundary I am building</h3><p>The voice pipeline interprets what the caller may have said. The conversation engine decides what information is missing, what needs to be repeated, and when the caller has to confirm a correction. Neither the speech model nor the language model owns the booking.</p><p>Simplified, the flow looks like this:</p><p>Caller → Telephony → Voice Pipeline → Conversation Engine → Validated Application Services → Booking Data</p><p>The result then travels back through the same layers to the caller. The important line is the one between the conversation engine and the application services. The AI-assisted layer produces a proposal. Deterministic code decides whether that proposal can become a valid command. Database constraints and concurrency controls provide the last line of defence when several operations arrive at the same time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2pMZN4kbhLD6e67LWPiWgQ.png" /></figure><p><strong>Figure 1:</strong> A simplified request-and-response path. The AI-assisted layer interprets language; deterministic services own the booking decision.</p><p>The principle underneath it is one sentence: <strong>the AI interprets the caller, and deterministic services protect the action.</strong></p><h3>What the safety layer had to prove</h3><p>I am building this in phases. Phase 1 was measurement and instrumentation. Phase 2, the phase I have just finished, was the safety foundation around the appointment workflow itself, tested without a live phone line.</p><p>Some of the rules it had to satisfy:</p><ul><li>If a caller changes the date after the system repeats it back, the conversation returns to a defined earlier state. It does not improvise, and it does not quietly keep two conflicting dates.</li><li>If two callers try to reserve the same slot, the database — not only an application-level availability check — prevents both bookings from succeeding.</li><li>If an operation is retried after a timeout, the retry returns the original outcome instead of creating a second booking.</li><li>A failed reschedule must not destroy the caller’s original appointment. The change has to behave as one business operation, not two unrelated updates.</li></ul><p>These rules are far less impressive in a video than a natural-sounding reply. They are also the difference between an interesting demo and a system somebody can trust with a real booking.</p><h3>What still does not work</h3><p>I am not calling this production-ready, because it is not.</p><p>The realtime voice gateway is not implemented yet, and real phone-line integration belongs to the next phase. The current pipeline behaves like a measured batch workflow rather than a natural realtime conversation.</p><p>Bengali speech recognition is still unreliable on 8 kHz telephone-quality audio — that is where the language misdetection and the Devanagari transcript at the top of this post came from. I have listened to those recordings myself, and the audio is clear. The problem is in the model and its configuration, not in the media path.</p><p>Then there is latency. In one fully instrumented turn, processing took <strong>35,078 milliseconds</strong> — and that measurement does not even include the final moment when the caller actually hears the response. Nobody can have a natural phone conversation with a system that can take 35 seconds to answer a single turn.</p><p>Some of my early assumptions about that delay were also wrong. I blamed the CPU before I had complete stage-level evidence. After measuring the pipeline properly, I found that one of the loudest metrics was not measuring what I thought it was measuring. That investigation became Part 3 of this series.</p><h3>Why I am sharing the unfinished version</h3><p>It would be easier to wait until everything works, record a clean demo, and present the journey as a straight line. That version would hide the most useful parts.</p><p>The best lessons came out of failures:</p><ul><li>a missing database row after a confident “Booked” response</li><li>a retry that could have created a duplicate action</li><li>a queue metric that was actually measuring stale backlog age</li><li>a Bengali transcript that came back in the wrong writing system</li></ul><p>Each of these changed the architecture. Engineering decisions make far more sense when the failed assumptions are still visible next to them.</p><h3>What this series will cover</h3><p>This is the first part of an eight-part engineering series.</p><p><strong>Part 1 — What I am building, and what is still broken.</strong> The project boundary, the current state, and why I decided to share the journey publicly.</p><p><strong>Part 2 — A voice bot talks. A workflow agent has to be right.</strong> Why model output should become a proposal, never a database command.</p><p><strong>Part 3 — Where 35 seconds of latency actually goes.</strong> Stage-level measurements, a misleading queue metric, and why real-time factor mattered more than raw milliseconds.</p><p><strong>Part 4 — Why Bengali speech recognition breaks on telephone audio.</strong> 8 kHz input, language detection, script confusion, and the configurations I tested.</p><p><strong>Part 5 — Why the workflow uses a deterministic conversation state machine.</strong> Corrections, confirmation, silence, repetition, and controlled handoff.</p><p><strong>Part 6 — How the database protects booking integrity.</strong> Unique constraints, concurrency control, and transactional behavior.</p><p><strong>Part 7 — How idempotency and atomic rescheduling prevent duplicate or destructive actions.</strong> What happens when a successful operation appears to fail and gets retried.</p><p><strong>Part 8 — What Phase 2 proved, and what it did not.</strong> The testing strategy, the remaining risks, and the move to realtime telephony.</p><h3>What comes next</h3><p>Part 2 looks at the gap between a voice bot that produces a convincing sentence and a workflow agent that has to leave the system in a correct state. The rule at the center of that design is short:</p><blockquote><em>The model produces a proposal. It never produces a command.</em></blockquote><p>The implementation cost, the trade-offs, and the four layers of safety underneath that rule are the subject of the next article.</p><p>This system is unfinished. Some parts work, some are still too slow, and some are not built yet. That is exactly why I am writing it down now. I would rather publish the engineering record while the decisions are still being made than a success story with all the hard parts quietly edited out.</p><p>Part 2 coming soon, Follow along if you want the measurements as they come in.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b7b1baea8e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>