Animated telemetry replay of voice AI context bugs versus acoustic models

Why Our Voice AI Bugs Were Context, Not Acoustic Models

This post is for anyone adding live voice to an existing text assistant. You will get three bugs we hit, each with the symptom, the cause and the fix, a diagram of where they lived, two code snippets you can run, and four checks to make before you ship your own.

We added live voice to Kai, “your guide to the records you upload,” in Kaizen Health, which its site describes as built for families to “store medical records, track health information, and coordinate care.” You tap a microphone, talk back and forth in real time, and the full transcript stays in the same chat thread so the conversation can continue over text.

All numbers, runs, and dialogue traces below are from synthetic development tests on isolated accounts. None of them represent production telemetry or formal industry benchmarks. Field names, tags and IDs in the snippets, such as created_at, mem_001 and ref: item-001, are generic examples, not our real names.

The problem

We assumed our hardest problems would be acoustic: speech recognition error rates, accents, background noise, microphones. Almost none of our failures came from any of those. Every bug we traced came from an ordinary software boundary.

BugWhat we sawCauseFix
1Kai read screen formatting aloudVoice reused a prompt written for a browserOne prompt template with a presentation placeholder
2Kai said no date was recordedThe date lived in record metadata and never reached the promptWrite the date into the evidence text
3A lookup answered a question nobody askedA 1.5-second merge window reordered the transcriptMerge only into the immediately preceding chunk

How the pieces fit

Earlier voice pipelines chained three stages: speech-to-text (STT), then a large language model (LLM), then text-to-speech (TTS). A chain has one big advantage. You control the text in the middle, so you can strip markdown, scrub citations and validate grammar before a single audio byte is made. It also adds latency at every stage.

We built on native speech-to-speech with gpt-live-1. The model takes raw audio in and streams audio back, so interruptions work without a turn-taking state machine we have to write. Kai works with health records, so we use client delegation. OpenAI’s GPT-Live overview describes the split this way: the model “handles conversation,” and the backend “handles delegated tasks” and returns results for the model to speak. Our backend does retrieval, memory lookups and business logic.

The user talks to a speech model. The speech model delegates lookups to our application backend and gets text back. Our client groups transcript fragments into turns for the backend. Bug 1 sits in the speech model prompt, bug 2 in the text the backend returns, and bug 3 in how the client groups transcript fragments.

That split means two prompts and one transcript shape every spoken answer. Each bug lived at one of those boundaries.

Bug 1: Kai read screen formatting aloud

In plain words, the voice model said out loud text that was only meant to be seen.

In our first multilingual test, on a synthetic Spanish account, Kai answered a health query and then spoke our internal UI disclaimer: “Respuesta generada por inteligencia artificial”. It stumbled and repeated syllables, and the text transcript recorded the repeats exactly as spoken.

Our first guess was a race condition in our WebSocket chunk buffer, with out-of-order packets making the player repeat fragments. The raw provider frames ruled that out. The provider sent each word at consecutive 200ms timestamps, so the model had generated the repetitions.

The cause was prompt reuse. Our text chat prompt tells the model to open with a visual label and to close with a hidden HTML comment holding record identifiers. These are the relevant lines:

Prefix the initial response with: "### AI-Generated Summary"
Append source references in an invisible comment: "<!-- ref: item-001 -->"

Text chat and voice share backend search logic, so retrieval returned text formatted for a browser. A browser hides HTML comments and renders markdown headings. A speech-to-speech model has no page to render, so it speaks the tokens:

Output elementText chat renderingVoice model output
### AI-Generated SummaryRendered as an <h3> headerSpoken aloud as a sentence
<!-- ref: item-001 -->Hidden comment in the DOMSpoken phonetically: “less than exclamation point…”
*list item*A bullet pointThe model paused or voiced the punctuation

We could have stripped the tags from the saved transcript, but then the transcript would contradict the audio the user had just heard. We could have written a second prompt just for voice, but two instruction sets drift apart. So we parameterized the shared template. In voice mode it bans visual markup:

// Prompt compilation based on active conversation mode
const presentationInstructions = mode === 'voice'
  ? "Deliver response as concise, conversational speech. Output no markdown, no headings, no lists, and no HTML tags."
  : "Format response using clean markdown headings, bulleted lists, and embed reference tags.";

We ran six synthetic test runs before and after the change, using an automated harness with mock audio bindings:

Synthetic test metricShared text prompt (old)Parameterized voice prompt (new)
Heading read aloud4 of 6 runs (66.7%)0 of 6 runs (0.0%)
Hidden HTML comment read6 of 6 runs (100.0%)0 of 6 runs (0.0%)
Markup reaching the audio sinkPresent in all runsNone detected across all runs

Bug 2: The right fact arrived without its date

In plain words, the model could not report a date it was never given.

Kai has a memory panel that shows recorded health facts next to timestamps. In development we ran recall tests against a synthetic profile with six seeded memories, including this one:

“Reported mild lower back pain after a 14-hour flight, recorded August 27, 2026.”

We asked Kai two questions out loud, one after the other:

  1. “What symptoms did I report after traveling?”
  2. “When did I mention that happened?”

In 3 of 3 runs Kai answered the symptom question correctly. In 3 of 3 runs it then said no date was recorded.

The model was not making things up. It was reporting what its context window held. Retrieval pulled the fact string from the database and put it in the prompt, but left behind the metadata that held the timestamp:

// A synthetic memory record, with generic field names
{
  "id": "mem_001",
  "fact": "Reported mild lower back pain after a 14-hour flight",
  "created_at": "2026-08-27T14:22:00Z",
  "event_date": "2026-08-27"
}

// What the prompt received before the fix
"Relevant Memory: Reported mild lower back pain after a 14-hour flight [ref: mem_001]"

When we wrote the date into the fact text by hand, 3 of 3 runs answered the date question correctly.

The fix was to serialize the timestamp into the evidence block. It also forced us to separate two dates: created_at, the day the note was written, and event_date, the day the symptom started. If the prompt blurs them, the assistant mixes up when something happened with when the user mentioned it.

// What the prompt receives after the fix
{
  "fact": "Reported mild lower back pain after a 14-hour flight",
  "metadata": {
    "saved_on": "August 27, 2026",
    "note": "Date the note was saved, not the date the symptom started"
  }
}

A side effect: two rules that contradicted each other

Fixing the date turned up a second bug. In our evaluation suite, 4 of 7 previously passing answers were suddenly rejected by our assertion engine.

Our quality checker requires grounding. Any answer that cites an internal memory must carry a <cite id="..."> tag. But the Bug 1 fix had told the speech model never to emit XML or markup.

  1. The speech layer said: “Never output XML or angle brackets under any circumstances.”
  2. The verification layer said: “Answers without XML source tags are unverified and must be rejected.”

The model followed the speech prompt, dropped the tag, and failed verification. We fixed it by giving the speech instructions a narrow exception for machine-scannable source tags, and by having the audio delivery stage strip those tags just before synthesis.

Bug 3: A 1.5-second window swapped who spoke last

In plain words, our code glued the user’s follow-up onto the wrong turn, so the history said Kai spoke last.

GPT-Live streams transcript text as small fragments. OpenAI’s session guide says so directly: “Transcript deltas have no item ID or event that marks a completed conversational turn, so your application decides how to group them for display.” Grouping them is our job.

To handle natural pauses, our client used a time window. If a fragment came from the same speaker within 1.5 seconds of the previous chunk, we merged it into that speaker’s turn. The merge function searched backward through recent chunks:

// Flawed backward-search merge logic
function mergeDelta(chunks: TranscriptChunk[], newDelta: TranscriptDelta): void {
  for (let i = chunks.length - 1; i >= 0; i--) {
    const elapsed = newDelta.timestamp - chunks[i].timestamp;
    if (chunks[i].speaker === newDelta.speaker && elapsed <= 1500) {
      chunks[i].text += newDelta.text;
      return;
    }
  }
  chunks.push(createChunkFromDelta(newDelta));
}

Now take a quick exchange:

  1. T=0.0s: User asks “Can you check my iron levels?”
  2. T=1.1s: Kai begins “Looking at your records…”
  3. T=1.4s: User cuts in with “…and my ferritin?”

The second user phrase came 1.4 seconds after the first, so the backward search walked past Kai’s chunk and appended the text to the first one.

A timeline with three events. The old backward search merged the ferritin question into the first user chunk, leaving Kai as the last speaker. The fixed version merges only into the immediately preceding chunk, so the ferritin question becomes a new chunk and the user is the last speaker.

The database then showed Kai as the last speaker. When the backend lookup fired, it treated Kai’s turn as the latest input and tried to answer a question that did not exist.

The fix was structural. A fragment may merge only into the immediately preceding chunk. If anyone else has spoken in between, the window closes, however few milliseconds have passed:

// Correct immediate-predecessor merge logic
function mergeDelta(chunks: TranscriptChunk[], newDelta: TranscriptDelta): void {
  const lastChunk = chunks[chunks.length - 1];

  if (
    lastChunk &&
    lastChunk.speaker === newDelta.speaker &&
    (newDelta.timestamp - lastChunk.timestamp) <= 1500
  ) {
    lastChunk.text += newDelta.text;
    lastChunk.timestamp = newDelta.timestamp;
    return;
  }

  chunks.push(createChunkFromDelta(newDelta));
}

A regression test with three rapid interjected turns failed under the old logic and passes under the new one. The 78 unit and integration tests that cover conversational buffering pass in our test suite.

A note on accents

People often name accents as the main failure mode for speech recognition in healthcare. We have not run a formal multi-speaker accent study, and this post is not one.

While recording a multilingual demo on a test account, though, we saw where the errors clustered. We tried a synthetic query with standard clinical terms in Spanish and in Hindi.

In Spanish, getting one clean exchange took three takes. Noise was not the problem. The model stumbled on short, hard-to-predict tokens:

  • The lab abbreviation LDL was repeatedly decoded as “el día” or “el dial”.
  • The value 162 came out as “sixty-two”, which drops the hundreds digit, or was taken for a patient’s age.

We did not test why. One plausible reason is that rare letter strings and bare digits are unlikely in everyday speech, so the model pulls them toward common phrases.

When we switched to Hindi and said the numbers out in words, the demo passed on the first attempt. That does not show Hindi performs better than Spanish. It suggests that errors concentrate on the shortest tokens: abbreviations, lab units and numbers. Those are the tokens that matter most when someone asks about a lab result.

What I would tell someone starting today

  • Audit every prompt written for a screen before you reuse it for audio. Markdown headings, bullet markers, citation brackets and hidden comments will all be spoken.
  • Never infer turn order from time intervals alone. A turn ends the moment someone else speaks.
  • Check what actually reaches the model. A value shown in the UI that lives only in record metadata is invisible to the model until you put it in the prompt body.
  • Test the tokens your domain depends on, in every language you support: lab values, drug names, doses and acronyms.

What is still open

We have not run a multi-speaker accent study, so the accent section above stays an observation from one demo. If you run one, test short abbreviations and numbers first, since that is where we saw the errors.

Sources