Repository navigation
fix: use shared retry defaults for Interactions backoff - #3318
Sun-Wukhan wants to merge 4 commits into
Conversation
Updated comments for clarity on backoff shape and retry options.
Clarify default behavior for retry options in docstring.
Add tests for retry configuration in translate function
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Hi @Sun-Wukhan, |
chrikrah
left a comment
There was a problem hiding this comment.
@Sun-Wukhan this fixes #3317 as I filed it, and the code is ready to merge from my side. With the issue's script, both clients now wait the same time at 2410af6:
$ python repro.py # #3317 script, attempts=4, jitter=0, head 2410af6 (base afb10e8)
models.generate_content: 4 requests, gaps [1.0, 2.0, 4.0] s, ServerError
interactions.create: 4 requests, gaps [1.0, 2.0, 4.0] s, InternalServerError
# same script with google_genai.py from afb10e8: interactions gaps [0.5, 1.0, 2.0] s
$ python -m pytest -q google/genai/tests/interactions/test_retry_options.py
13 passed # head
1 failed, 12 passed # google_genai.py from afb10e8: test_translate_retry_config_delay_defaults_match_api_client
# not run: mypy, the async client
non-blocking: a client with no retry_options moves too. Its first wait goes from 0.5 s to 1 s, because _translate_retry_config always builds a config. I'd keep it: one default is what the issue asks for.
The cla/google check is still red, and the bot says nobody looks at the PR until it passes. Can you sign the CLA?
|
Thought I signed it, my bad chief. On it. |
|
I signed it! |
Fixes #3317
_translate_retry_configingoogle/genai/_gaos/google_genai.pydefaulted the Interactions backoff to local constants (500ms initial, 8000ms max) and left jitter unset, while the rest of the SDK uses the documentedHttpRetryOptionsdefaults from_api_client(1.0s initial, 60.0s max, 1.0 jitter). The same unsetHttpRetryOptionstherefore produced two different retry schedules in one client.This change takes all three defaults from
_api_client(_RETRY_INITIAL_DELAY,_RETRY_MAX_DELAY,_RETRY_JITTER), the same wayattemptsalready falls back to_api_client._RETRY_ATTEMPTS. The local_DEFAULT_INITIAL_INTERVAL_MS/_DEFAULT_MAX_INTERVAL_MSconstants are removed; explicit per-field options still override.Tests: two new cases in
google/genai/tests/interactions/test_retry_options.pyassert that unset delay options produce the shared defaults (1000ms / 60000ms / 1000ms) and that explicit values still override. The full file passes locally (13 tests).