Protect a Response from Voice Interruption

Use response protection when a custom agent has one response the visitor should hear in full — for example a safety instruction, a payment confirmation, a short legal notice, or a farewell. Send a data-response-policy part before the response text. Mirako keeps playing that response while discarding visitor speech that overlaps it.

Protection is per response. It starts with the current turn's response, covers every text block, tool step, and media segment in that response, and ends after playback completes. The next response returns to normal interruption behavior unless your endpoint sends the policy again.

What the visitor experiences

  • The avatar keeps speaking when the visitor talks over a protected response.
  • Speech that overlaps the protected response is discarded. Mirako does not turn it into a queued follow-up question after playback ends.
  • Capture keeps running, so the visitor does not need to restart the microphone. After playback ends, Mirako waits for a brief quiet moment before accepting fresh speech; a visitor who starts exactly as the avatar finishes may need to pause and repeat.
  • The visitor can still stop the response from the page controls, type a prompt instead of speaking, or leave and hang up. Protection controls voice interruption; it does not lock the visitor into the call.
  • Protection ends when playback finishes, when the response is stopped or replaced, or when the response fails. If playback cannot complete within the runtime's bounded wait, Mirako cancels the protected response rather than leaving voice input suppressed indefinitely.

Managed agents keep their standard interruption behavior. Response protection is a custom-agent stream control; a managed agent cannot set it through its instruction or MCP tools.

Send the policy part

Emit the policy as a persistent AI SDK UI message stream part before the first non-empty text delta of the response:

http
HTTP/1.1 200 OK
Content-Type: text/event-stream
x-vercel-ai-ui-message-stream: v1

data: {"type":"start","messageId":"msg_789"}

data: {"type":"data-response-policy","id":"policy_1","data":{"voice_interruptible":false}}

data: {"type":"text-start","id":"text_1"}

data: {"type":"text-delta","id":"text_1","delta":"Please listen to this complete instruction before replying."}

data: {"type":"text-end","id":"text_1"}

data: {"type":"finish","finishReason":"stop"}

data: [DONE]

With an AI SDK UI message stream writer, write the same part before merging or writing the text stream:

ts
writer.write({
  type: "data-response-policy",
  id: "policy_1",
  data: { voice_interruptible: false },
});

Emit the part from your endpoint code, at the point where your application decides the response must play in full. Treat it as application logic, like a tool result or routing decision. Asking the language model to print a policy marker in its answer text does not enable protection.

Part fields

Field Required Description
type Yes "data-response-policy".
data Yes An object containing exactly one field: voice_interruptible.
data.voice_interruptible Yes Boolean. Use false to protect the response. true keeps ordinary interruption and is the default when no policy is sent.
id No A nonempty stream-part identifier of up to 128 Unicode characters.
transient No Omit this field or set it to false. Transient policy parts are outside this contract.

Ordering and completion rules

Mirako validates the policy strictly because a late or ambiguous marker cannot protect speech that has already started:

  • Send the policy before the first non-empty text-delta. A policy that arrives after response text fails the response.
  • You may repeat the same policy before text — for example if two layers of your stack both emit defaults — as long as every copy agrees. A conflicting true/false pair before text fails the response.
  • Unknown fields inside data, a missing boolean, or extra fields beside voice_interruptible fail the response.
  • Finish a protected response with a successful final finish part: omit finishReason or set it to "stop", then send data: [DONE]. A stream that only closes, sends [DONE], or ends with text-end / finish-step has not certified a successful protected response.
  • Protection applies when Mirako accepts the policy. If the visitor already interrupted and cancelled the run before the policy arrived, the policy cannot revive that cancelled response. Send it at the start of the response stream.
  • Once accepted, the policy covers the whole response, including later text blocks after tool calls. It never carries into the next turn.

Playback completion

Mirako releases protection from playback evidence, not from the end of your text stream:

  • Avatar and video conversations: the browser reports when the final media segment and the audio/video playback queues have drained. Mirako validates that report against the response and the visitor's capture boundary before accepting new voice input.
  • Browser voice and SIP calls: the voice gateway reports a playback boundary after its paced or provider-confirmed output completes, plus a short safety allowance. Twilio calls use the provider's playback marks; Asterisk calls use the gateway's correlated media-buffer completion.

These signals confirm that the playback pipeline or provider handoff finished. They cannot prove that sound reached the visitor's speaker or handset — a muted device, a suspended browser tab, or a provider-side delay can still prevent the visitor from hearing part of a response. Keep critical content available through another channel, such as on-screen text or a follow-up message, when hearing it is essential.

Protect a farewell

You can combine response protection with End of Conversation so the farewell itself is not cut off by visitor speech. Send the policy before the farewell text, then the end request before the successful finish:

http
data: {"type":"data-response-policy","data":{"voice_interruptible":false}}

data: {"type":"text-delta","id":"text_1","delta":"Thanks for calling. Your reference number is 4821. Goodbye!"}

data: {"type":"data-end-interaction","id":"end_1","data":{"reason":"completed"}}

data: {"type":"finish","finishReason":"stop"}

data: [DONE]

The call closes after the protected farewell finishes playing. Speech during the farewell is discarded, and the ending still completes through the normal playback boundary rather than the visitor's voice.

Agent Link turns carry the same AI SDK stream parts, so an adapter sends data-response-policy in a chunk frame before the response text, with the same field and finish rules. Agent Link is provisioned per integration — confirm response-protection support for your linked deployment with the Mirako team before relying on it. See Agent Link.

Going Next

Dive Deeper