Repository navigation
Description
Bug description
When configuring automatic retry with random exponential backoff for genai.Client objects, disabling the variance/jitter of retry wait times is impossible using genai.types.HttpRetryOptions objects; setting the variance/jitter to 0.0 automatically defaults to 1.0 instead upon initialization of genai.Client objects.
The issue occurs in google/genai/_api_client.py in retry_args():
jitter=options.jitter or _RETRY_JITTER,
The falsy check returns False when 0.0 is passed. Since jitter is typed and validated as Float | None, this line should instead be:
jitter=options.jitter if options.jitter is not None else _RETRY_JITTER,
or:
jitter=_RETRY_JITTER if options.jitter is None else options.jitter,
Expected behaviour
Initializing a genai.Client object with the http_options.retry_options parameter set to:
genai.types.HttpRetryOptions(jitter = 0.0)
should return a genai.Client object that has no variance/jitter added to retry wait times.
Actual behaviour
Initializing a genai.Client object with the http_options.retry_options parameter set to:
genai.types.HttpRetryOptions(jitter = 0.0)
returns a genai.Client object that is initialized to add a random value between 0 seconds and 1 second to retry wait times.
Steps to reproduce
- Run the following code:
from google import genai
client = genai.Client(
vertexai=True,
project="foo",
location="foo",
http_options=genai.types.HttpOptions(
api_version="v1",
retry_options=genai.types.HttpRetryOptions(
jitter=0.0,
),
),
)
print(client._api_client._retry.wait.jitter)
The above block will print:
1
Environment details
- Programming language: Python
- OS: Any
Activity
Venkaiahbabuneelam commentedon Feb 9, 2026
Hi @RealErikHuebner,
Thanks for reaching out us
When you pass jitter = 0.0 condition treats as a false and assigning default value is 1.
For now workaround you can try with below code:
from google import genai
client = genai.Client(
vertexai=True,
project="foo",
location="foo",
http_options=genai.types.HttpOptions(
api_version="v1",
retry_options=genai.types.HttpRetryOptions(
jitter=0.0,
),
),
)
print(client._api_client._retry.wait.jitter)
if hasattr(client._api_client._retry, 'wait'):
client._api_client._retry.wait.jitter = 0.0
print(f"Jitter is now: {client._api_client._retry.wait.jitter}")
Thanks
RealErikHuebner commentedon Feb 14, 2026
Hi @Venkaiahbabuneelam
Thank you for the response and the provided workaround; I've confirmed that it does indeed work.
Are there any plans to include the changes I proposed above in a coming release? Since
jitteris typed and validated asFloat | None, this change should be safe, unlessjitter = 0.0being reset to default is intended behaviour?RealErikHuebner commentedon Feb 14, 2026
Also would you be able to tell me what the corresponding workaround would be for
genai.client.AsyncClientobjects? i.e. when retrieving and usingsome_client.aioobjects wheresome_clientis of typegenai.Clientand has already been initialized?Venkaiahbabuneelam commentedon Feb 17, 2026
Hi @RealErikHuebner,
Thank you for your feedback. We appreciate you taking the time to share your thoughts with us, and we'll be filing a feature request.
fix: honor an explicit zero in HttpRetryOptions delay fields
fix: honor an explicit zero in HttpRetryOptions delay fields
fix: honor an explicit zero in HttpRetryOptions delay fields