Repository navigation
fix(tavus): don't retry 4xx when calling the Tavus API, and keep the provider's error - #7494
Merged
Merged
Conversation
sidxh
force-pushed
the
fix/tavus-start-retry
branch
from
September 26, 2026 19:20
31e9e40 to
874ba5c
Compare
…provider's error Re-raise non-retryable APIStatusError immediately, retry 5xx and network errors max_retry times after the first attempt, and let the final error be the provider's status (or an APIConnectionError chained to the network error) instead of a generic "after all retries". Same shape as livekit#7314 for Anam.
sidxh
force-pushed
the
fix/tavus-start-retry
branch
from
September 26, 2026 19:26
874ba5c to
edb3ed5
Compare
longcw
approved these changes
Sep 30, 2026
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.
TavusAPI._postretries every failure, including 4xx responses that can never succeed. With a wrong API key the avatar takes about 4 seconds to fail, logs three tracebacks, and ends with a retryableAPIConnectionError("Failed to call Tavus API after all retries")that has lost the 401 and the response body.The loop catches
Exception, which includes theAPIStatusErrorit raises itself for a non-2xx response, logs each one withlogger.exception, and always finishes with a generic, unchainedAPIConnectionError. It also runsrange(max_retry), one attempt fewer than the other avatar plugins.This is the same change #7314 made for Anam. A non-retryable
APIStatusErroris re-raised immediately. 5xx and network errors are retriedmax_retrytimes after the first attempt with a warning (status code only, no payload), and the final error is the provider'sAPIStatusError, or anAPIConnectionErrorchained to the network error.Against a local server with default connect options, on
main: a 401 takes 4.00s, three tracebacks, genericAPIConnectionError; a persistent 503 is the same. With this change a 401 raisesAPIStatusError(status_code=401)on the first attempt with no traceback, 503, 503, 200 still succeeds, and a persistent 503 raisesAPIStatusError(status_code=503)after four attempts (6.01s, one more attempt than before, matching Anam). Five tests added in a newtests/test_plugin_tavus.py; the four retry-classification ones fail onmain, and one covers a 2xx with a malformed JSON body, which now fails once with a non-retryableAPIConnectionErrorinstead of re-sending a POST Tavus already accepted.Closes #7493.