Voice AI

Four Agents on a Phone Call: The Architecture Behind Svarra

Building a multi-agent voice platform that books appointments over a real phone line. The orchestration, the state problem, the failure modes nobody warns you about.

Text agents can take their time. If a chat agent thinks for four seconds, the user sees a typing indicator and waits.

A voice agent that thinks for four seconds has created a silence. The person on the other end says "hello?", the turn-taking logic fires, and now two parties are talking over each other. The conversation never recovers.

Svarra is a multi-agent voice automation platform I built for inbound and outbound calling. Lead qualification, appointment booking, follow-ups. This is what the architecture ended up looking like and which of my assumptions did not survive contact with a live phone line.

#Why four agents and not one prompt

The obvious first build is one large prompt with every instruction in it: greet, qualify, check the calendar, book, confirm, handle objections, escalate.

That works until it doesn't, and the way it fails is instructive. A single prompt holding all of those responsibilities has no notion of where it is in the conversation. It will offer to book an appointment before qualifying, confirm a slot it never checked, or re-greet someone in the middle of a booking. Nothing is hallucinating exactly. The model is simply being asked to track too much implicit state in a context window that is also full of transcript.

Splitting into four specialised agents gave each one a narrow job and, critically, an explicit place in a state machine:

The conversation agent owns the actual dialogue. Greeting, turn-taking, tone, objection handling. It is the only agent the caller hears.

The qualification agent extracts structured information from what was said, who are they, what do they want, do they match the criteria. It outputs fields, not sentences.

The scheduling agent talks to the calendar. Availability, holds, bookings, conflicts. Deterministic, boring, and the one with the real side effects.

The supervisor watches the transcript and decides when something has gone wrong enough to hand off to a human or end the call. It never speaks.

The separation matters most for the ones with side effects. The scheduling agent books a real slot in someone's real calendar. Keeping that behind a narrow interface with validated inputs, rather than something a large prompt might decide to do mid-sentence, is the difference between a product and a liability.

#The state problem

Four agents means four things that each think they know what is happening. They do not, unless you make them.

I tried passing state through the conversation itself, each agent reading the transcript and inferring the current situation. This fails subtly and constantly. Agents disagree about whether the caller has been qualified. The scheduling agent proposes a slot, the conversation agent offers a different one because it read an earlier part of the transcript.

The fix was a single source of truth, held outside the agents entirely:

python
@dataclass
class CallState:
    call_id: str
    phase: Phase            # GREETING | QUALIFYING | SCHEDULING | CONFIRMING | CLOSING
    caller: CallerFacts     # progressively filled, never guessed
    held_slot: Slot | None  # a real calendar hold, with a TTL
    turn_count: int
    escalated: bool

Every agent reads this before acting and proposes changes to it, rather than mutating it directly. The orchestrator applies the changes. One writer, many readers, which is the oldest fix in distributed systems and applies here exactly as it does anywhere else.

phase doing real work is the important part. The conversation agent in QUALIFYING is not permitted to offer a time slot. Not discouraged by prompt, not permitted, because the scheduling tool is not in its tool list in that phase. Capability gating by state removed an entire category of embarrassing behaviour that no amount of prompt wording had fully fixed.

#Webhooks, idempotency, and the double booking

The orchestration runs on event-driven webhooks: telephony provider to backend, backend to workflow automation, automation to calendar and CRM.

Every webhook provider retries. Yours will be called twice. Occasionally three times, sometimes minutes apart, sometimes out of order.

The first version of the booking handler was not idempotent, and I found out in the way everyone finds out: a caller got two identical calendar invitations and a slightly confused confirmation message.

Now every state-changing operation carries a deterministic key derived from the call and the intent, the handler checks whether that key has already been processed, and replays return the original result instead of doing the work again. This is standard practice and I knew it, and I still skipped it on the first pass because the happy path worked.

If your handler is not idempotent, it is not finished. It just has not been retried yet.

#The failure modes nobody warns you about

Silence is ambiguous. Three seconds of nothing can mean: the caller is thinking, the caller is checking a calendar, the line dropped, or they walked away. Each needs a different response and the audio stream gives you no way to distinguish them. I ended up with graduated prompting. A gentle "take your time" at four seconds, a check-in at eight, a wrap-up at fifteen, which handles thinking and checking well and degrades acceptably for the other two.

Transcription errors are not random. They cluster on exactly the words that matter: names, numbers, dates, email addresses. "Fifteenth" and "fiftieth" are one phoneme apart and mean very different things to a calendar. Anything with real consequences gets read back for confirmation. It makes the call slightly longer and removes the worst class of error.

Barge-in breaks your turn model. Real people interrupt. If your agent is halfway through a sentence and the caller starts speaking, you must stop generating, stop playing audio, and discard the rest of the planned turn, including whatever tool call that turn was leading toward. Handling this properly was more engineering than any of the agents themselves.

Latency compounds across the chain. Speech-to-text, agent reasoning, possibly a tool call, text-to-speech, audio delivery. Each one is "fast". Together they can easily reach two seconds, which is the edge of where a conversation starts feeling broken. The practical fix was to start speaking before finishing thinking, emit a short acknowledgement ("let me check that for you") while the scheduling call is in flight. Not a trick; it is what a human receptionist does, and for the same reason.

Cost per call is a design constraint, not an afterthought. Four agents means multiple model calls per turn. A twelve-turn conversation can be fifty model calls if you are careless. The supervisor runs on a much smaller model and only every few turns. The qualification agent runs once per extractable fact, not once per turn. All of this came from reading the per-call cost breakdown on the dashboard and being unhappy with it.

#Testing something that talks

Conventional testing assumes a deterministic function. A voice agent is a non-deterministic system reacting to a non-deterministic human over a lossy channel. Most of what I knew about testing did not transfer directly.

What ended up working was three layers, none of which is "unit test the prompt".

Transcript replay. Every real call's transcript is stored. A change to any agent is replayed against a corpus of stored transcripts, and the resulting state transitions are compared to what happened originally. This does not check that the wording is good. It checks that the decisions are stable. If a prompt tweak suddenly causes forty historical calls to skip qualification, you know before you ship. This caught more regressions than anything else I built.

Adversarial scripted calls. A set of scripted callers that behave badly on purpose: interrupting constantly, answering a different question than the one asked, going silent, giving a date that does not exist, changing their mind three times, saying "yes" to something they clearly do not mean. Each one has an expected outcome. Usually "escalates cleanly" rather than "completes the booking." Graceful failure is the thing being tested.

Shadow mode on real traffic. New agent versions run alongside the live one on real calls without being heard, and their proposed actions are logged and compared. The disagreements are where the interesting information is. A new version that would have booked a different slot on 8% of calls is telling you something important, regardless of which version is right.

The thing all three have in common is that they test behaviour under uncertainty rather than output correctness. There is no single right response to "um, actually, can we do Thursday instead. No wait." There are only responses that keep the conversation recoverable and responses that do not.

One number worth tracking above the rest: the proportion of calls that reached a clean terminal state, meaning booked, declined or escalated with context, versus calls that simply ended. A call that just stops is the signature of the agent getting confused and the caller giving up, and it will not appear in any accuracy metric. That ratio, tracked weekly, has been the single best early-warning signal for the whole system.

#What I would keep and what I would change

Keep: the explicit state machine, capability gating by phase, one writer for state, read-back confirmation on anything consequential, and the supervisor as a separate non-speaking observer. That last one in particular, having something watching the conversation that has no stake in continuing it is what makes escalation work.

Change: I would build the cost and latency dashboard on day one instead of week six. Both of those numbers are architectural constraints, and I designed for a while without being able to see them. Several decisions I made early got reversed once the numbers were visible, and they would not have been made that way if the numbers had been there from the start.