Repository navigation
Don't retry create_phone_call without an idempotency_key - #552
Closed
zorionarrillaga wants to merge 1 commit into
Closed
zorionarrillaga wants to merge 1 commit into
zorionarrillaga wants to merge 1 commit into
Conversation
Without a key the API can't tell a retry from a new call, so the default retry after a timeout, a dropped connection or a 5xx could dial to_number twice. Calls made without idempotency_key are now sent once; calls with a key keep their retries and resend the same key.
Contributor
|
Thanks for the repro and tests. This is addressed in retell-sdk 6.2.11 for Python and TypeScript, through shared request defaults and Python generator support. Phone-call, SMS-chat, and batch-call creation now default to zero retries, including sync/async Python and phone calls with an Verified against both published packages with mocked transports. Closing this as addressed by the release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What broke
create_phone_callisPOST /v2/create-phone-call, and it places an outbound phone call. The Stainless base client retries it up to 2 times (DEFAULT_MAX_RETRIES):A timeout or a 5xx can come after Retell has already dialled, such as when carrier or LLM setup is slow. If the caller passed no
idempotency_key, the API can't tell the retry from a new call. The callee's phone rings twice, both calls are billed, and the caller only gets back the secondcall_id.How it was reproduced
I used a local mock of
POST /v2/create-phone-callon 127.0.0.1 only; no Retell account or real API was involved. The mock records each POST as a dialled call and holds the first reply for 2.5 s. The client runs withtimeout=1.0. Oneclient.call.create_phone_call(from_number=..., to_number="+14155550199"):main(8fd9533)call_1,call_2)call_1,call_2)call_1)call_2call_2APITimeoutErroridempotency_key="order-42-call", the branch still retries, and both attempts carry the same key. The mock does not dedupe, so it dials twice there. The real API dedupes on the key according to its docs (read, not tested).maindiffers from the 6.2.10 wheel only in twotypes/*list_response.pyfiles.What changed
resources/call.py,create_phone_call, in both sync and async: whenidempotency_keyis not given, the request options setmax_retries=0. A comment explains why. Nothing else in the request changes.idempotency_keykeeps every retry, with the same key in the body;create_web_call, retries as before.tests/test_phone_call_retries.py(new, 22 cases). It uses a scriptedhttpxtransport through the realRetell/AsyncRetellclients:client.with_options(max_retries=5);idempotency_keyin both bodies (9 cases);create_web_callis still retried on 503;How it was tested
main(every "sent once" case). The 11 "still retried" cases pass on both. All 22 pass on the branch.pytest, their config with-n auto), Python 3.9.12, dev deps from theirrequirements-dev.lock: 518 passed, 2345 skipped on the branch. HEAD gives 496 passed, 2345 skipped. The skips are their disabled mock-server tests.ruff check .(0.14.13) andruff format --checkon both changed files: clean.pyright(1.1.399, their pin):0 errors, 0 warnings, 0 informations.mypy .(1.17.0):Success: no issues found in 193 source files.python -c 'import retell'works.