1. Why voice AI breaks differently than text chat

When a chatbot hallucinates inside an internal dashboard, a user clicks refresh. When an autonomous outbound voice agent calls real people on the PSTN network, every bug has immediate financial, legal, and reputational consequences: dialing the same contact twice from concurrent workers, transferring a call to an attacker-supplied number, or reporting optimistic "closed sales" on a leaderboard.

"Start with simple prompts, optimize them with comprehensive evaluation, and add multi-step agentic systems only when simpler solutions fall short. ... Consistently, the most successful implementations weren't using complex frameworks or specialized libraries. Instead, they were building with simple, composable patterns."
Anthropic Engineering, Building effective agents

While scaling Power Dialer from a single AI helper into a concurrent campaign fleet, the guiding principle became clear: treat the conversational LLM as an untrusted execution plane, never as an authority over money, telephony routing, or business metrics.

2. Three planes & server-authorized call transfers

Instead of giving an LLM free-form tools that accept phone numbers or prices, Power Dialer enforces a strict split:

  • Human Control Plane: Defines campaigns, versioned immutable playbooks/personas pinned at call creation, supervises live transcripts via Laravel Reverb, injects live nudges, and performs QC review.
  • Server Authorization Plane: Runs deterministic Laravel services for DNC/consent eligibility, calling hours, spend caps, atomic lead leases, typed transfer resolution, and append-only outcome recording.
  • AI Execution Plane: Listens and speaks in real time. When a transfer is needed, the model emits only a typed reason. TransferResolver maps that reason to an authorized destination (human queue, AI pool, or approved PSTN target) and forwards a redacted context package.
Server-Authorized Transfer Boundary Contract Pattern
// Model tool call (untrusted input boundary):
{ "tool": "request_transfer", "args": { "reason": "billing_escalation", "summary": "..." } }

// Server TransferResolver (Laravel):
// 1. Validates reason against campaign's TransferPolicy allow-list
// 2. Maps reason -> typed TransferDestination (never accepts raw phone/ID from LLM)
// 3. Builds redacted TransferContextPackage + splits opener/closer attribution

3. Atomic contact leases & swappable realtime audio lanes

Race Condition

Read-then-write lead picking

Querying WHERE status = 'pending' then updating inside a worker lets two concurrent executors dial the same lead within milliseconds, and leaves leads stranded if a worker crashes.

Shipped Protocol

Conditional atomic lease + reconcile

Deterministic fleet allocation assigns owners upfront; execution takes a conditional lease with heartbeat renewal, scheduled expiry reaping, idempotent webhooks, and dialer:reconcile drift checks.

Behind one conversation engine, Power Dialer supports three swappable voice transports: turn-based Twilio <Gather>, Twilio ConversationRelay, and full-duplex OpenAI Realtime μ-law audio bridged through a stateless Node 20 sidecar on port 8091. Global and per-agent feature flags behind a circuit breaker let operators roll back voice behavior immediately as configuration rather than waiting on a deploy.

4. Stopping reward hacking & encoding compliance

"How important evals are to the team is a major differentiator between folks rushing out hot garbage and those seriously building products in the space."
Eugene Yan, Patterns for Building LLM-based Systems & Products

When an AI sales agent scores its own call as a "hot lead" or "sale", feeding that signal straight onto revenue leaderboards invites specification gaming. Power Dialer enforces three structural defenses:

  • Claimed vs. QC-verified separation: Calls write canonical states to an append-only outcome ledger; scoreboards display only sales confirmed by the QC review queue.
  • Static reward-hacking scanner: A build check fails CI if any model-generated interest score is consumed by a ranked, paid, or headline surface.
  • Compliance in code: Non-disableable guardrail floors enforce EU AI Act Art. 50 disclosure, transcript-only sentiment scoring (never acoustic emotion inference, respecting Art. 5(1)(f)), German §7 UWG consent provenance, and per-call Twilio webhook token validation.

5. Bonus Architecture: 100% Local Privacy-First Voice Loop (CoachAI)

While Power Dialer orchestrates cloud telephony at fleet scale, CoachAI (built at Solution Planets with FastAPI, Next.js, and Docker Compose) proves the opposite end of the spectrum: an interactive Socratic voice tutor running completely on local hardware with zero cloud API calls and zero external OS FFmpeg subprocesses.

CoachAI Local Real-Time Voice Pipeline Zero Cloud Calls · FFmpeg-Free PyAV
CoachAI Local Real-Time Voice Pipeline Diagram Shows Next.js browser mic capturing WebM Opus audio, FastAPI decoding buffers in-memory via PyAV, Moonshine STT transcribing locally, Ollama DeepSeek-R1 14B generating Socratic responses with emotion tags, and Kokoro TTS streaming synthesized speech back to the student UI. Browser Mic Next.js App WebM / Opus PyAV + STT In-memory decode (No FFmpeg CLI) Moonshine STT Ollama LLM DeepSeek-R1 14B Socratic state + emotion tags Kokoro TTS Emotion-guided neural stream Audio Stream
Decoding browser WebM/Opus frames in Python memory with PyAV avoided spawning heavy FFmpeg child processes per utterance while running entirely offline via Docker Compose.

6. Actionable Tips & Tricks Checklist

CHECK 01

Pin AI config bundles per call at creation

Freeze persona, playbook, and guard versions onto the call row so later audits can reproduce exact call behavior.

CHECK 02

Log explicit STT locale per tenant

Defaulting multilingual calls to English silently corrupts DE/TR transcripts. Pass explicit language codes per campaign.

CHECK 03

Keep hermetic tests decoupled from brokers

Power Dialer runs 1,644 PHPUnit tests without Reverb or Redis running, keeping CI fast while guarding core state machines.

CHECK 04

Never publish unmeasured latency claims

Instrument per-span timers (LatencyRecorder) early, and mark live caller-heard SLOs as unverified until staged rollout traffic runs.

Read full Power Dialer case study Next article: Document AI & DB Boundaries →