Realtime Voice AI & Conversational Audio · 7 min read

Building Conversational Voice Agents: Tools, State, and Guardrails

Learn how to connect realtime voice models to backend tools, maintain conversational state, and enforce safety guardrails on live audio.

By aijobsok Editorial TeamPublished 2026-07-19Updated 2026-07-28

Executing tool calls during a live audio stream

Just like text agents, realtime voice models can call tools—querying databases, updating reservations, or triggering webhooks. However, in a voice stream, dead silence while a tool executes for 1.5 seconds creates anxiety, making the user wonder if the call dropped. Voice architectures handle this by having the model emit conversational filler audio ('Let me look that up for you...') while the tool executes asynchronously.

Conversational fillers and asynchronous tool execution

When a tool call is emitted over the realtime session, the system can either: 1) Rely on the model's native filler tokens before tool emission; or 2) Have the client/backend immediately stream a subtle listening earcon or spoken acknowledgment while waiting for tool return. Once the tool resolves, the JSON result is appended to the session, and the model seamlessly continues speaking with the new information.

Realtime session configuration with tool definitions
json
{
  "model": "voice-realtime-v1",
  "modalities": ["audio", "text"],
  "instructions": "You are a friendly customer concierge. Speak concisely in 1-2 sentences. Always acknowledge tool lookups with a quick verbal filler.",
  "voice": "alloy",
  "input_audio_format": "pcm16",
  "output_audio_format": "pcm16",
  "turn_detection": {
    "type": "server_vad",
    "threshold": 0.5,
    "prefix_padding_ms": 300,
    "silence_duration_ms": 500
  },
  "tools": [{
    "name": "check_order_status",
    "description": "Lookup delivery status of an order by ID",
    "parameters": {"type": "object", "properties": {"order_id": {"type": "string"}}, "required": ["order_id"]}
  }]
}

Session state, context memory, and conversation summaries

Because audio streaming sessions can last 10, 20, or 30 minutes, keeping thousands of raw audio tokens in context will quickly hit window limits and drive up cost. The voice session manager must periodically condense completed conversational turns into concise text summaries, preserving key user preferences and decisions in context while unloading old raw audio frames.

Audio safety guardrails and real-time moderation

Safety moderation on live voice presents distinct challenges. Running text-based guardrails requires transcribing the audio stream in parallel with lightweight models, checking for toxic speech, self-harm signals, or prompt injections. If a violation is detected mid-sentence, the session controller can cleanly fade out audio and steer the conversation back to safety.

Testing and evaluating conversational voice experiences

Evaluating voice agents requires listening tests beyond text metrics: measuring First Speech Latency (FSL), barge-in interruption accuracy, pronunciation accuracy of domain jargon (medical terms, product SKUs), naturalness of breath pauses, and tool completion success rates under noisy real-world acoustic conditions.

Practical exercise

Design the tool schema for a restaurant reservation voice agent. Write the system prompt specifying how the agent should handle brief silences, how it should acknowledge tool execution ('Checking available tables for 7 PM...'), and how it should confirm details phonetically before executing a booking.

By aijobsok Editorial TeamPublished 2026-07-19Updated 2026-07-28

Sources and further reading

These primary or specialist references informed the concepts in this guide. Product details can change, so verify current documentation before implementation.