FIX: retry backoff never waits with default wait_seconds; make reraise meaningful - #2596
Open
NullLabTests wants to merge 2 commits into
Open
FIX: retry backoff never waits with default wait_seconds; make reraise meaningful#2596NullLabTests wants to merge 2 commits into
NullLabTests wants to merge 2 commits into
Conversation
…uate_python_code docstring
…aise meaningful - Default wait_seconds=0.0 kept delay at 0, so exponential backoff never actually slept. Default is now 1.0, matching tenacity's wait_exponential multiplier. - The first sleep used wait_seconds * exponential_base instead of wait_seconds because delay was multiplied before sleeping. Sleep now happens before the delay grows, so waits are 1s, 2s, 4s, ... - reraise=False raised the raw exception like reraise=True. It now raises RetryError wrapping the last exception, matching tenacity.
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.
Fixes #2586
Three problems in
smolagents.utils.Retrying:Backoff never waited with the default
wait_seconds=0.0.delaystarts at0.0anddelay *= exponential_base * (1 + jitter * random())keeps it at0.0, so theif delay > 0guard never sleeps. Any caller using the default getsmax_attemptsback-to-back calls. Default is now1.0, matching tenacity'swait_exponentialmultiplier.First sleep was
wait_seconds * exponential_base, notwait_seconds. The delay was multiplied before sleeping, so await_seconds=1.0produced waits of 2s, 4s, 8s... instead of 1s, 2s, 4s... The sleep now happens before the delay grows.reraisehad no effect. Both branches were identicalraise, soreraise=Falsebehaved likereraise=True. Following tenacity,reraise=Falsenow raises aRetryErrorwrapping the last exception;reraise=Truere-raises the original.Tests added in
tests/test_utils.pycover all three fixes plus the no-retry path.Note:
models.pypasseswait_seconds=RETRY_WAIT(60) explicitly, so in-repo behavior is unchanged; the default change only affects external users who relied on the (broken) default.