Evalgent
Back to Blog
Voice AI Testing

Voice Agent Interrupted Tool Calls: Retries, Duplicates and Idempotency

Deepesh Jayal
15 min read
Voice Agent Interrupted Tool Calls: Retries, Duplicates and Idempotency
On this page
A calendar day with two identical 3 PM appointment cards stacked on one slot, a red pill reading one call, two bookings, and a key field showing none.

A caller says, "Book me Thursday at 3." The agent calls the scheduling API. Two seconds in, the caller adds, "Actually, wait." The agent stops talking, loses the thread, and asks again. The tool fires a second time. Both requests succeed.

The caller hears one confirmation. The calendar holds two appointments. No error was raised, and the transcript looks clean.

This is the failure behind voice agent interrupted tool calls, and it is an unknown outcome problem. It sits between the interruption handling you already test and the tool-calling tests you already run. This post covers what the framework does, why the outcome is unknown, how idempotency keys fix it, and a test plan you can copy.

We do not re-explain adjacent topics. For undoing bad writes, see voice agent rollback actions. For tools that fail while the agent claims success, see detecting silent tool failures. Here we focus on the in-flight call.

The four states of an interrupted tool call

A tool call that is cut short ends in one of four states. Call each an in-flight tool call until you know more. The agent usually cannot tell which.

1. Never sent. The interruption landed before the request left your process. Nothing happened.

2. In flight, will land. The request reached the server. The server is still working and will finish.

3. Landed, result lost. The write succeeded. The response never reached the agent, or reached it after the agent moved on.

4. Failed. The server rejected or crashed before writing.

States 1 and 4 are safe to retry. States 2 and 3 are not. From the agent's side, all four look the same: no result.

Timeline with four lanes, caller, agent, tool client and booking system, showing a request sent, a caller interruption, a second request, and two writes landing.

The AAIF article Where voice agents fail in production, part 2 (Steve Kearns, October 29, 2026) says it directly: "A timeout cannot safely be treated as proof that nothing happened." It adds that "retrying without checking can produce two bookings."

Stripe documents the same logic for payments. In its advanced error handling guide, a connection that closes before a response leaves you unable to know "whether Stripe received or executed the request." Restoring connectivity "doesn't tell you whether the original request succeeded."

A voice call adds a second source of ambiguity. The network is not the only thing that cuts the call short. The caller can too.

Four moments when a call gets cut short

An interrupted tool call is not one event. It is four, and each needs its own test.

Barge-in during tool call. The caller speaks while the agent waits on a tool. The framework may cancel the tool, let it run, or drop the result. The caller often says something new, such as a different time.

A caller says "wait" mid-lookup. This is a read, not a write. It is usually safe, but it still matters. The agent may speak a stale result after the caller has moved on.

The tool is slow past N seconds. A voice agent tool call timeout is the most common trigger. Your tool client times out at 5 seconds. The booking system takes 7. The write lands after the agent has already retried or apologised.

The caller hangs up mid-write. The session ends while the request is in flight. The write may still land, with nobody on the line to confirm it.

The first two are barge-in problems. The second two are timing problems. All four end the same way: an action of unknown status. Barge-in detection itself is covered in how to evaluate interruption detection. This post starts after the agent has stopped talking.

What your framework does by default

Frameworks differ on what happens to a running tool when the caller interrupts. Read your version's docs. As of November 18, 2026, the two docs pages say this.

FrameworkWhat the docs sayWhat it means for writes
LiveKit Agents"A tool continues running in the background until it returns; interrupting the agent doesn't cancel the work."A booking call keeps running after barge-in.
LiveKit async tools"By default, async tools finish what they're doing regardless of what the user does." Cancellation is opt-in.A write finishes unless you opt in to cancel it.
Pipecatcancel_on_interruption defaults to True: "the call is cancelled if the user interrupts."The handler is cancelled on barge-in.
Pipecat timeouts"A call that runs past its deadline is cancelled."A slow write is cancelled on the client side.

Sources: LiveKit tool definition and async tools, and the Pipecat function calling guide.

These match the AAIF claims. LiveKit tool code keeps running by default. Pipecat cancels in-flight calls by default.

Neither default gives you safety. LiveKit keeps the write running, so the result can arrive late and unused. Pipecat cancels your handler, but our reading is that cancelling a coroutine does not recall an HTTP request already on the wire. The server can still finish it. Pipecat's own page adds that work "the handler spawns into a task of its own isn't cancelled with it."

LiveKit explains why cancellation is opt-in: "most tools (orders, writes, payments) aren't safe to interrupt partway through." That is the right instinct. An interrupted write is the dangerous kind.

Two more details matter for duplicates:

  • LiveKit's async tools detect duplicates "by tool name only, not by arguments," and on_duplicate defaults to allow. Two booking calls with different arguments are both allowed unless you change the mode.
  • Pipecat lets you set cancel_on_interruption=False and timeout_secs per tool, for example with @tool_options(cancel_on_interruption=False, timeout_secs=30), as its docs show.

The docs we read do not say what happens to an in-flight tool when the caller hangs up. Treat that as untested until you test it. Treat voice agent interrupted tool calls as their own scenario family. Your transport, session close and cleanup code decide the outcome.

Why voice agent interrupted tool calls cause duplicates

Every duplicate booking voice agent incident starts the same way. The agent retries because it has no result. Several things push it there.

The LLM sees an empty or error result and decides to try again. A framework retries on timeout. A caller repeats the request after silence. A prompt says "if the tool fails, try once more." Each is reasonable alone.

Now add the race. The first request is still running when the second arrives. That is a double booking waiting to happen. The server has no way to know they are the same intent. It runs both.

Here is an illustrative worked example. The numbers are assumptions, not measurements. Say your client timeout is 5 seconds. Your scheduling API's slowest 1% of writes take 6 seconds or more. Those 1% of writes time out on the client and still land.

At 10,000 booking calls a month, that is about 100 writes whose outcome the agent cannot see. If the agent retries every one, up to 100 duplicates appear. Each is a double-booked slot or a second charge. The formula is simple: duplicates at risk = calls x share of writes slower than your timeout x retry rate.

The fix is not a longer timeout alone. A longer timeout only moves the tail. It also makes the caller wait in silence. The fix is making the retry safe.

Idempotency keys: the retry that cannot double-book

An idempotent operation has the same effect whether you run it once or many times. MDN defines it as an HTTP method whose "intended effect on the server of making a single request is the same as the effect of making several identical requests." GET, PUT and DELETE are idempotent by that definition. POST is not guaranteed to be. The normative definition of HTTP method semantics is in RFC 9110; the wording above is MDN's.

Creating a booking is usually a POST. So it is not idempotent unless you make it so. An idempotency key does that.

Stripe's idempotent requests reference is the canonical description. As of November 18, 2026, for API v1:

  • The client generates the key. Stripe suggests V4 UUIDs or another high-entropy string, up to 255 characters.
  • Stripe saves the status code and body of the first request. A retry with the same key "return the saved response, including 500 errors."
  • Keys can be removed once they are at least 24 hours old.
  • Reusing a key with different parameters produces an error.
  • All POST requests accept keys. GET and DELETE do not need them.

An IETF draft, The Idempotency-Key HTTP Header Field, proposes the same pattern for POST and PATCH. It is an Internet-Draft, and the version we read is marked expired. Use it as background, not as a standard.

Why voice agents need a deterministic key

Good idempotency voice agent design starts with the key. Stripe's SDKs can generate a random key per call. That does not help here. If the agent re-invokes the tool after an interruption, a fresh random key looks like a new request, and you get the duplicate.

Derive the key from the intent, not the attempt. Build it in your tool wrapper, never in the LLM:

key = hash(call_id + operation + canonical arguments)

Same call, same operation, same booking slot: same key. The retry collapses into the original. Here is a simplified wrapper. The endpoint and field names are hypothetical.

import hashlib, json
import httpx

def idempotency_key(call_id: str, op: str, args: dict) -> str:
    canon = json.dumps(args, sort_keys=True, separators=(",", ":"))
    return hashlib.sha256(f"{call_id}|{op}|{canon}".encode()).hexdigest()[:32]

async def create_booking(call_id: str, args: dict) -> dict:
    key = idempotency_key(call_id, "create_booking", args)
    async with httpx.AsyncClient(timeout=8.0) as client:
        r = await client.post(
            "https://scheduler.example/v1/bookings",
            json=args,
            headers={"Idempotency-Key": key},
        )
    r.raise_for_status()
    return r.json()

Persist the key before you send. Stripe advises the same when retries cross process restarts: "generate and persist a key for the operation and supply it to every attempt."

Two traps:

  • Canonical arguments. The LLM may send "3pm" once and "15:00" the next. Normalise to one form first. Otherwise the keys differ and the dedupe fails. The spoken-argument problem is covered in tool argument accuracy.
  • A real change of mind. If the caller says "make it 4 instead," the arguments change, so the key changes. That is correct. But the 3 PM write may have landed. You must resolve it, by cancelling it, before you create the 4 PM one. Otherwise you hold both.

When the API has no idempotency key

Many scheduling, CRM and payment tools do not accept a key. You still have options.

Read before you retry. After a tool call timeout, query the system for what you tried to create. Match on something you control, such as the call id stored in a notes or external-reference field. If it exists, the write landed. Use it. If it does not, retry once.

Use an external reference. Stripe suggests including a local identifier in object metadata "so you can match an object received through a webhook to your local records." The same trick works anywhere with a free-text or custom field.

Add a uniqueness constraint in your own layer. Keep a small ledger table with a unique index on the derived key. Insert the key as pending before the call, and update it to done with the returned id. A second attempt finds the row and reads the status instead of writing again.

Prefer idempotent verbs. A PUT that sets a slot to a state is safer than a POST that appends one.

The read-back is only as good as your timing. A write still in flight may not be visible yet. Wait a short, bounded interval, check again, and then decide.

Decision tree for an unknown tool outcome: is it read only, is there an idempotency key, does a read back find the record, then retry, use the record, or hand off.

What the agent should say

The agent's words must match what it knows. Most damage comes from claiming certainty it does not have.

State after the cut-offWhat you knowWhat the agent should do
Read-back finds the recordIt landedConfirm it. Do not write again.
Read-back finds nothing, key presentProbably not landedRetry once with the same key.
Read-back unavailableUnknownSay a confirmation will follow. Queue a reconciliation job.
Caller changed the requestOld write may existResolve the old write, then create the new one.
Caller hung upNobody to confirmReconcile after the call. Send a text if policy allows.

Never say "it didn't go through" unless you know. Never say "you're booked" unless you read it back. The in-between sentence, "I've sent that request, and you'll get a text to confirm," is honest and cheap. Check your disclosure and consent rules in AI disclosure for voice agents before any follow-up message.

The slow path also has a cost. Silence while a tool runs reads as latency to the caller. Voice agent latency: what to measure shows which clock the caller feels. A filler phrase before a slow write is better than a long gap that invites an interruption.

How to test voice agent interrupted tool calls

A transcript will not show a duplicate write. You need the audio, the tool log and the system of record. Follow these steps.

1. List your write tools — Mark each by reversibility: read, soft write, hard write, money. Start with the hard writes and money. The classes in voice agent rollback actions work as a starting point.

2. Stub the backend with fault injection — Make the stub able to delay a response, drop it, return a 500, and succeed silently after the client has timed out. You need all four, because they map to the four states above.

3. Script the four interruption moments — Caller interrupts during a booking call. Caller says "wait" mid-lookup. Tool slow past your timeout. Caller hangs up mid-write. Run each against each write tool.

4. Pin the caller behaviour — Vary interruption level and response delay. A caller who cuts in at 300 ms behaves differently from one who speaks after 2 seconds.

5. Assert on the record, not the speech — After each call, query the backend. Count rows for that call id. The pass rule is exactly one record, or zero when the caller cancelled.

6. Assert on the tool log — Count calls per operation. Check that retries reuse the same key. Check that a changed request cancels the earlier write.

7. Assert on what the agent said — It must not confirm a booking it never read back. It must not deny one that landed.

8. Repeat and run on every change — Interruption timing is random. Run each scenario several times per prompt or tool change, and see coverage math in the tool-calling test library.

Test matrix of five interruption scenarios against expected tool calls, expected records and expected agent speech, with an exactly once pass rule.

A simplified harness check, in pytest style. The helper names are hypothetical.

def test_barge_in_during_booking(sim, backend):
    call = sim.run_scenario("book_thursday_3pm", interrupt_at_ms=1200)
    rows = backend.bookings(call_id=call.id)
    assert len(rows) == 1, f"expected exactly one booking, got {len(rows)}"
    keys = {c.idempotency_key for c in call.tool_log if c.name == "create_booking"}
    assert len(keys) == 1, "retry used a different key"
    assert not call.said_confirmed_without_record()

The same harness works for integration testing of voice agents. Validate the arguments too, using function schema validation tests.

The pass rule: action executed exactly once

Define one metric per write tool: action executed exactly once. For each call, count successful writes to the system of record for that intent. Pass is one. Fail is zero when the caller confirmed, or two or more at any time.

Zero is a failure too. A cancelled in-flight call with no retry loses the booking the caller was told they got. Keep it separate from duplicates so you can see which way you fail.

Where Evalgent fits

Evalgent generates test scenarios from the agent's prompt and flows, and runs them over phone, SIP or WebRTC with caller profiles that set interruption level and response delay. A "caller interrupts during booking" scenario is then a profile plus a script, not a hand-run call.

Calls are judged from the audio rather than the transcript alone, so a barge-in that the transcript drops still shows up. "Action executed exactly once" can be set up as a custom metric on every call, judged against the audio and the tool logs you provide. If the agent says "you're booked" over a double write, the judge has evidence for both. Human review checks the verdict. Our write-up on LLM and Jev as a judge for tool calling covers the tool side.

In production, customers push recordings. Calls are transcribed, mapped to scenarios and judged, and tool-call failures are flagged. Use that to catch the interrupted-call pattern on live calls, and pair it with a nightly check of your own system of record.

Production monitoring for voice agent interrupted tool calls

Tests find the failures you thought of. Group by call id to spot any retry duplicate action voice agent bugs. Production finds the rest. Two checks are cheap.

A duplicate query. Group writes by customer, slot and operation within a short window. Flag any group with more than one row from the same call id or phone number. A query like this finds the double-books before the customer does:

SELECT customer_id, slot_start, COUNT(*) AS n
FROM bookings
WHERE created_at >= now() - interval '1 day'
GROUP BY customer_id, slot_start
HAVING COUNT(*) > 1;

A call-to-record join. For each call that ended during or just after a tool call, check the record. Calls that ended with a tool call in flight are your risk set. See post-call write-back testing for the reconciliation pattern, and tool call accuracy for the metrics around it.

Log the idempotency key, the attempt number and the outcome on every tool call. Without those three fields, you cannot tell a retry from a repeat.

Frequently asked questions

What happens to a tool call when the caller interrupts?

It depends on your framework and settings. LiveKit's docs say a running tool "continues running in the background until it returns." Pipecat's docs say a function call is cancelled on interruption by default. Either way, a write already sent may still land. Check the record before you retry.

Does a timeout mean the tool call failed?

No. A timeout only means no response arrived in time. The write may have landed, may still be running, or may have failed. Stripe's docs say connectivity problems leave you unsure whether the server "received or executed the request." Treat the outcome as unknown until you read it back.

How to prevent duplicate bookings in a voice agent?

Send a deterministic idempotency key with every write, derived from the call id, the operation and the normalised arguments. Persist it before you send. Where the API has no key, read the record back before any retry. Then test barge-in, slow responses and hang-ups against each write tool.

Should a voice agent retry a failed tool call?

Only when a retry cannot repeat the effect. Reads can be retried freely. Writes need the same idempotency key, or a read-back that proves nothing landed. Retry once, not in a loop. If the outcome stays unknown, say a confirmation will follow and reconcile afterwards.

How to make voice agent tool calls idempotent?

Build the key in your tool wrapper, not in the LLM. Hash the call id, the operation name and canonical arguments. Send it in an Idempotency-Key header, or store it in a ledger with a unique index. Stripe's API v1 keeps keys for at least 24 hours.

How to test barge-in during a tool call?

Script a caller who interrupts at set times while a stubbed backend delays its response. After the call, count records for that call id and compare tool-log keys. Pass when exactly one record exists and retries reuse the same key. Vary interruption timing and repeat the run.

What if the caller hangs up while a write is in flight?

The write may still land with nobody to confirm it. A hang up mid-write is the least visible case. The docs we read for LiveKit and Pipecat do not say what happens to an in-flight tool on hangup, so test your own stack. Reconcile after the call by joining call logs to your records, and message the customer if policy allows.

Can the LLM generate the idempotency key?

It should not. A model may produce a different value on each attempt, which defeats the purpose. Build the key in code from stable inputs. The same call, operation and normalised arguments must always give the same key, so a retry collapses into the original.

The bottom line

A voice agent interrupted tool call leaves the outcome unknown, and a retry without a check is how a caller gets two bookings or two charges. Make every write retry-safe with a deterministic idempotency key, read back before you retry, and test barge-in, slow responses and hang-ups by counting records, not by reading transcripts.

Related Articles