End of Conversation
A visitor can end a voice conversation by leaving the page. Your agent can also decide that the conversation is complete and request a call ending. Managed agents use the built-in end_interaction tool; custom agents send an end request through their response stream.
Your agent's instructions can describe suitable stopping points. The model considers that guidance alongside the conversation when deciding whether to request an ending.
Managed-Agent Endings
A managed agent calls end_interaction with {"reason":"completed"}. The tool records the request and returns {"status":"scheduled","reason":"completed"}. The agent then produces a short, natural farewell after the acknowledgment, in the same turn.
Once the response finishes successfully, the agent runtime forwards the end request to the voice pipeline. The voice gateway coordinates the final speech output and connection shutdown. Scheduling happens inside the agent runtime; call closure follows through the gateway.
The gateway uses the explicit end request to initiate closure, so the agent can say goodbye during a conversation without ending the call.
Speech and Call Closure
The managed runtime forwards an end request after a successful native tool execution, subsequent response text, and normal response completion. If a response fails, is canceled, or ends prematurely, the runtime discards its pending end request. An interruption or a later visitor turn can also invalidate a scheduled ending.
Mirako coordinates closure with speech output. Playback still depends on the client and connection, and transport failures or drain timeouts can interrupt the final audio.
Closure ends the current voice call. The agent configuration and its route links remain available for future conversations.
Built-In Tool Availability
Mirako's managed runtime provides end_interaction by default, alongside any external MCP tools you configure. The agent's tools JSON describes those external MCP servers; the native call-ending tool is already available inside the runtime.
The tool's supported input is {"reason":"completed"}. The runtime associates the request with the current interaction and handles the identifiers needed for closure.
Custom Agents
Your custom endpoint can request the same call closure by sending a persistent data-end-interaction part in its AI SDK UI message stream. Your endpoint decides when to end, streams its farewell as normal assistant text, and includes the end request before completing the response. Mirako associates the request with the current call and handles closure through the voice pipeline.
The following response streams a farewell and requests an ending:
HTTP/1.1 200 OK
Content-Type: text/event-stream
x-vercel-ai-ui-message-stream: v1
data: {"type":"start","messageId":"msg_farewell"}
data: {"type":"text-start","id":"text_1"}
data: {"type":"text-delta","id":"text_1","delta":"Thanks for calling. Goodbye!"}
data: {"type":"text-end","id":"text_1"}
data: {"type":"data-end-interaction","id":"end_1","data":{"reason":"completed"}}
data: {"type":"finish","finishReason":"stop"}
data: [DONE]
The end-request part has these fields:
| Field | Required | Description |
|---|---|---|
type |
Yes | "data-end-interaction". |
data |
Yes | An object containing exactly {"reason":"completed"}. |
id |
No | A nonempty stream-part identifier of up to 128 Unicode characters. |
transient |
No | Omit this field or set it to false to send a persistent part. Mirako ignores transient end requests. |
Mirako commits the end request after the response stream completes successfully. Include a finish part; its finishReason can be omitted or set to "stop". The final [DONE] closes the stream. If the response fails, is aborted, or becomes stale, Mirako discards the pending ending.
The voice pipeline then coordinates speech output and call closure as described in Speech and Call Closure. See Building a Custom Agent for the full endpoint contract.
Going Next
- Agent Greeting: Learn how Mirako Interactive opens a conversation.
- Share & Embed: Connect visitors through a route link or iframe.