Why does a voice agent call the same tool twice?
Duplicate tool calls in a voice agent have ordinary causes, and each repeat looks like new work to your backend. The table lists the usual causes and what changes on the wire when each one happens.
On gpt-live-1 phone calls the slowest tenth of tool calls took 6.91 s or longer, within about a second of the 8 s default timeout. The sample is 1,008 tool calls of 20 ms or more in 450 calls, 11 September to 29 October 2026, and one assistant made 62% of the gpt-live-1 phone tool calls.
In the same period the voice stayed quiet for at least a median 5.07 s before the result audio on gpt-live-1 phone tool turns (851 tool turns in 425 calls). A pause that long gives the caller time to repeat the request while the first call is still running.
Interruptions behave differently by stack. On OpenAI Realtime, tool calls still queued when a caller interruption cancels their response are dropped before any request is sent, and APIFleet does not cancel a call it has already started. On Gemini Live, a caller interruption can cancel a tool call that APIFleet has already sent, so your endpoint may still complete the write while the model never receives a result for that call id.
| Cause | What happens | Identifier on the repeat | What protects you |
|---|---|---|---|
| Tool timeout | APIFleet stops waiting (8 s by default) and gives the model an error result while your endpoint may still finish the write | A new call_id if the model asks again | A lookup by business key before any new write |
| Model asks again | After an error or an unclear result, the model issues the same tool call once more | A new call_id | A key on the business operation |
| Caller repeats or corrects | A silent wait invites the caller to restate the request, or to change one detail of it | A new call_id | Same key means a repeat, a changed detail means an update |
| Caller talks over the agent | On OpenAI Realtime, queued calls of a cancelled response are dropped before sending; on Gemini Live a call may be cancelled after the request went out, and its result is discarded | A new call_id on any later attempt | Never read an unspoken result as a failed write |
| Proxy or gateway resend | A component in front of your handler sends the same request again | The same call_id and body | The key, or the call_id for this case only |
| Webhook retry | Your reply took longer than the default 5 s budget, the request failed in transit, or you answered 429 or 5xx | The same delivery id, body and signature | A unique constraint on the delivery id |
What APIFleet sends and what it retries
An HTTP tool call is one signed request per model tool call, a POST by default. The JSON body carries call_id, name, arguments, context and created_at, and the X-APIFleet-Call header repeats the call_id. A tool set to GET sends no body, so its arguments arrive in the query string.
That call_id is the model provider's tool call id: the id OpenAI Realtime or Gemini Live gave that call, or on a cascading assistant the id the chat model gave it. APIFleet makes one attempt, and a timeout, network failure or non-2xx reply goes back to the model as an error result instead of a retry.
Within one model response, APIFleet sends tool calls one at a time, in order. Overlap still happens when an attempt APIFleet gave up on is running while the next request arrives, so your handler has to tolerate two requests for one operation at once.
| Event | Identifier you receive | Does APIFleet retry? | Key on |
|---|---|---|---|
| HTTP tool call | X-APIFleet-Call header and call_id in the body: the model provider's tool call id for that one call | No. One attempt per model tool call; a failure goes back to the model as an error result | The business operation |
| Call webhooks (call.started, call.ended) | X-APIFleet-Delivery header and delivery in the body | Yes, on a timeout, 429 or 5xx: by default up to 4 retries with exponential backoff, kept in the sender's memory, so a crash can drop them | The delivery id; reconcile gaps with GET /calls |
| Assistant lifecycle and simulation webhooks (assistant.created, assistant.updated, assistant.deleted, simulation.completed) | The same header and body field | Yes: a durable outbox keeps retrying for 24 hours by default, with no attempt limit | The delivery id |
| Your POST /calls/outbound request | The ids in a 201 reply, nothing if the request times out | No automatic retry and no universal Idempotency-Key | A lookup in GET /calls before you repeat |
Why call_id is not an idempotency key
RFC 9110 calls a method idempotent when several identical requests have the same intended effect on the server as one. A tool can be configured as GET, POST, PUT, PATCH or DELETE, but the method name does not make your handler safe, because your code has to provide that effect.
The call_id answers a different question: which tool call is this, so the model can match the result. OpenAI describes the Realtime call_id as a system-generated ID for that function call, and a model that asks again after a timeout issues a new one. A key built from it dedupes a request that was resent, not a request that was repeated.
Two other obvious keys fail too. The request body includes created_at, which changes on every attempt, so a hash of the whole body never matches a repeat. A hash of the raw arguments breaks as soon as the model rephrases a value, such as a time sent as 19:00 once and 7 pm the next time.
Stripe's API shows the pattern when the client is a program. For its v1 API, Stripe saves the status code and body of the first request made with a key, returns them for later requests with the same key, including 500 errors, and errors if the parameters differ. In a voice agent the client is a language model, so derive the key on your side from data you control.
Which idempotency key fits which tool?
Build the key from the business operation: the venue, the customer id that your lookup step resolved, and the booked time in UTC. Do not use a phone number as typed or spoken, because (312) 555-0100 and +1 312 555 0100 are the same caller but different strings. In a local test, a key built from the digits of the phone text created a second booking when the same caller's number arrived in a different format.
When no natural key exists, split the write in two. A prepare tool validates the request, stores it and returns an operation id with a read-back sentence, and a commit tool takes only that id. A repeated commit finds the same stored operation and returns its result, and the caller's confirmation applies to exactly the details that were stored.
| Tool type | Key that survives a model retry | What goes wrong without it |
|---|---|---|
| Lookup or availability check | None needed: a read is safe to repeat | A repeat costs time on the call, not data |
| Create a booking or order | Venue, resolved customer id and start time in UTC, or a prepare operation id | A second booking for the same caller and slot |
| Change a booking | The booking id plus the new values | A change applied twice, or a new booking created instead |
| Cancel a booking | The booking id: cancelling twice leaves it cancelled | An error on the repeat that makes the model say the cancellation failed |
| Send an SMS or email | Recipient, purpose and conversation id, plus the provider's own idempotency key if it offers one | The caller receives the same message twice |
Should a voice agent retry a tool call that timed out?
Not until you know whether the first attempt happened. A timeout means APIFleet stopped waiting, not that your endpoint stopped working, so the write may be committed, still running or never started. The model cannot tell which, because all three reach it as the same error result.
RFC 9110 says a client should not automatically retry a non-idempotent request unless it knows the semantics are idempotent or can detect that the original was never applied. A language model has neither, so your endpoint has to supply one of them: a key that makes the repeat harmless, or a lookup that shows what happened.
Keep the first response inside the budget. If the write can take longer than a few seconds, return in_progress with the operation id at once, finish the work in the background and give the model a status tool to ask again. Raising the tool timeout up to 30 s buys time but lengthens the silence on the line, and lowering it ends the wait sooner but turns slower writes into unknown outcomes.
Describe each status value in the tool's description so the model knows that in_progress means wait rather than repeat. On cascading assistants, set progress_message on a slow tool so the caller hears an update instead of silence; it reduces dead air but does not make a repeated write safe.
| What the model sees | What may have happened | Safe next step |
|---|---|---|
| An error that says the tool invocation failed (timeout or network) | The write never ran, is still running, or finished after APIFleet stopped waiting | Look the operation up by its key and repeat only if it does not exist |
| An error that names an HTTP 5xx status, plus your response body | Your gateway or app failed, and the write may already be committed | Reconcile exactly as for a timeout |
| An error that names an HTTP 4xx status, plus your response body | Your handler refused the request, normally before any write | Fix the input or ask the caller, then repeat |
| Your in_progress status | The first attempt is still running | Tell the caller it is being confirmed, then call a status tool |
| A stored result with duplicate true | A repeat of work that already finished | Say the same confirmation and write nothing new |
How to build a duplicate-safe tool handler
The handler needs one table with a unique constraint and one rule: claim the operation before you do the work. The IETF's Idempotency-Key draft, still an Internet-Draft in October 2026, suggests answering a retry that arrives while the first request runs with 409 Conflict. A tool reply goes to a language model, not a client library, and APIFleet passes a non-2xx status to the model as an error, so the steps below return 200 with an in_progress status.
- On any tool method except GET, verify X-APIFleet-Signature before parsing: compute sha256= plus the hex HMAC of the raw body with the tool's secret and compare it in constant time, checking the lengths first because timingSafeEqual throws when they differ.
- Build the operation key from business data your system resolved, such as venue id, customer id and start time in UTC, never from call_id, created_at or the raw argument text.
- Claim the key with one statement, INSERT INTO tool_ops (op_key, fingerprint, status) VALUES (?, ?, 'running') ON CONFLICT (op_key) DO NOTHING, a clause Postgres accepts (use your database's equivalent elsewhere), and read how many rows it inserted. The fingerprint holds the details that may legitimately change, such as party size.
- If one row was inserted, you own the operation: do the write, store the result on the same row with status done, and return it. If the write lives in your own database, do the claim and the write in one transaction.
- If no row was inserted, read the existing row. When it is done and its fingerprint matches, return the stored result unchanged; when it is still running, return in_progress with the operation id.
- If the fingerprint differs, for example a new party size, return a conflict that names the existing booking and points the model at your update tool, and never create a second booking silently.
- Return a repeat in the same success shape as the first call, with a duplicate flag if you like, and keep an error field or ok set to false out of it, because APIFleet records such a reply as a failed tool event.
- Give a running claim a lease: when its row is older than your longest write plus the tool timeout, check the downstream system for the operation before you retry or release it.
| Request | call_id | What the handler finds | What the model sees |
|---|---|---|---|
| 1. First request | call_A | Claims the key and starts a write that outlasts the timeout | An error: the tool invocation failed |
| 2. The model asks again while the write runs | call_B | The key is claimed and still running | Status in_progress |
| 3. The caller repeats later, time and phone re-formatted | call_C | The key is done and the details match | Status confirmed, the same booking reference, duplicate true |
| 4. A proxy resends request 1 | call_A | The key is done and the details match | The same stored result |
| 5. The caller changes the party size from 4 to 5 | call_D | The key is done but the fingerprint differs | Status conflict that names the existing booking |
| 6. The caller asks for the next hour instead | call_E | A different key, so a new claim and a new write | A second booking, because it is a different operation |
How to make a webhook handler idempotent
Webhook delivery is at least once while APIFleet is still retrying, not exactly once, so the same event can reach your endpoint more than once. Each event gets one delivery id, a UUID sent in the X-APIFleet-Delivery header and in the body as delivery, and every retry to an endpoint reuses that id, the same body and the same signature. Treat the id as the dedupe key, and because every endpoint subscribed to the same event receives the same id, key a table shared by two endpoints on the delivery id plus the endpoint.
The retry rules depend on the event. By default, call.started and call.ended are retried from memory: up to 4 retries, so 5 attempts, with waits of 1, 2, 4 and 8 s plus up to 250 ms of jitter each, and a crash can drop pending retries. For simulation.completed and the assistant.created, assistant.updated and assistant.deleted events, a durable outbox keeps retrying with no attempt cap, by default doubling the wait up to 5 minutes and stopping when a 24 hour window ends, after which the delivery is marked failed.
By default a call event therefore gets about 15 s of backoff in all, so an outage of a minute or more, or a crash before a retry, can lose it for good, and GET /calls is how you reconcile what you did not receive. By default the durable events survive a much longer outage, because they keep retrying until their 24 hour window ends.
By default, replies are expected within 5 seconds, and a slower reply counts as a failed attempt that is retried. If your handler does the business work inline and takes longer, the retry arrives while the first attempt is still running, and a check-then-insert guard lets both through. In a local test with APIFleet's own webhook sender and a shortened reply budget, that guard ran the work twice, while storing the delivery id first under a unique constraint ran it once, even when the first 200 was lost.
Verify the signature over the raw body, insert the delivery into a table keyed by delivery id, answer 200 straight away and do the work from that table. Answer 200 for a duplicate too, because any other 4xx is permanent and a 429 or 5xx asks for another retry. Use 401 only for a bad signature.
| Your reply | What APIFleet does | Use it for |
|---|---|---|
| 2xx within the default 5 s budget | Marks the delivery done and stops | A new delivery and a duplicate you already stored |
| No reply within that budget, or a network error | Counts a failed attempt and retries, even if your handler finished | Avoid it: store first, then do the work |
| 429 or 5xx | Retries with exponential backoff | A transient failure you want retried |
| Any other 4xx, such as 401 | Treats it as permanent and never retries | A request you will never accept, such as a bad signature |
How to test duplicates before callers do
Test the endpoint you will run in production. A simulation tool mock returns canned JSON in place of your endpoint, so it cannot show how your handler treats a repeat, although it can show what the model says after an in_progress or error result. To trigger a real timeout, set the tool's timeout to its lowest allowed value, 500 ms, and add a delay after the write in a test endpoint.
After real test calls, read tool_events in GET /calls. Two entries with the same tool name and equivalent arguments but different call_id values usually mark a model repeat, and on Gemini Live a cancelled status may mark a result that APIFleet discarded after an interruption.
| Case | How to trigger it | It passes when |
|---|---|---|
| Replay | Send the same signed request twice with curl | One row is written and both replies carry the same booking reference |
| Model repeat | Send the same business request, re-signed, with a new call_id, a later created_at and the time or phone number spelled differently | The same booking reference comes back and no second row appears, because the key uses resolved ids |
| Timeout then repeat | Set the tool timeout to 500 ms, delay your reply by a second after the write, then repeat the request | The first call times out, the booking exists once and the repeat returns it |
| Overlap | Send two identical requests at the same moment | One write happens and the other waits or returns in_progress |
| Changed detail | Repeat the request with a different party size or time | You get a conflict or an update path, never a silent second booking |
| Webhook replay | Post the same delivery id twice, once with a slow reply | The business effect runs once |
What to ask any voice platform about tool calls
Three answers decide how much duplicate protection you have to build: which identifier a tool request carries, what the platform retries, and what the model sees after a failure. For APIFleet HTTP tools the answers are the model provider's tool call id, no retry, and an error result that does not say whether the write happened.
Our comparison of six developer platforms covers per-minute cost, control and pilot fit rather than tool-retry behavior, so put the same three questions to each vendor before you rely on its tool calls for writes.
APIFleet behavior on this page was checked on 16 November 2026. The defaults quoted here, such as the 5 s webhook reply budget and the 8 s tool timeout, can change, so confirm them against the API documentation and your own test calls.
Continue with a practical next step
- Start with the voice agent tools checklist
- Where the seconds go on a voice agent tool turn
- Tool request headers and webhook retry rules in the docs
- API reference: outbound calls and their retry limits
- HTTP errors and retry behavior across the API
- Test failing tool calls and interruptions before release
- Compare six voice agent platforms for developers
Frequently asked questions
What is an idempotency key for a tool call?
An idempotency key is a stable identifier for one intended operation, such as one booking for one customer at one time. Your handler stores the first result under that key and returns it for every repeat. In a voice agent, build it from data your system resolved, not from call_id, which is new on every model retry.
Why does a voice agent call the same tool twice?
The model can retry after a timeout or an error, the caller can repeat or correct a request while a slow tool runs, an interruption can leave a result unspoken, and a proxy can resend a request. Each model retry is a new tool call with a new call_id, so it looks like new work unless you key the write on the business operation.
Should a voice agent retry a tool call that timed out?
Not until you know what happened. A timeout means APIFleet stopped waiting, not that your endpoint stopped, so the write may exist. Look the operation up by its key and repeat only if it is missing; with an idempotent write, a repeat is safe and returns the stored result.
How do I make a webhook handler idempotent when the sender retries?
Verify the signature over the raw body, insert the X-APIFleet-Delivery id into a table with a unique constraint, answer 200 for both new and duplicate deliveries, and do the work from that table. APIFleet can deliver the same event more than once, reuses the same delivery id, body and signature on every retry, and expects a reply within 5 seconds by default.
Does APIFleet retry HTTP tools or webhooks?
It does not retry HTTP tool calls: each model tool call gets one attempt, and a failure goes back to the model as an error result. Call webhooks (call.started and call.ended) are retried from memory after a timeout, 429 or 5xx, by default up to 4 times, while assistant lifecycle and simulation webhooks are retried from a durable outbox for 24 hours by default. APIFleet does not promise exactly-once delivery for either.
Sources and evidence
- APIFleet API documentation: HTTP tools and webhooks · observed 2026-11-16
- APIFleet: Voice agent tool call latency, tool or model? · observed 2026-11-16
- APIFleet API and MCP errors: retry behavior · observed 2026-11-16
- RFC 9110: HTTP semantics, idempotent methods (section 9.2.2) · observed 2026-11-16
- Stripe API reference: Idempotent requests · observed 2026-11-16
- IETF Internet-Draft: The Idempotency-Key HTTP Header Field (draft 08) · observed 2026-11-16
- OpenAI documentation: Realtime conversations, function calling · observed 2026-11-16
- Google Gemini API reference: Live API, tool call cancellation · observed 2026-11-16