Skip to content

fix: use shared retry defaults for Interactions backoff - #3318

Open
Sun-Wukhan wants to merge 4 commits into
googleapis:mainfrom
Sun-Wukhan:fix/interactions-retry-defaults
Open

Sun-Wukhan wants to merge 4 commits into
googleapis:mainfrom
Sun-Wukhan:fix/interactions-retry-defaults

Conversation

@Sun-Wukhan

Copy link
Copy Markdown

Fixes #3317

_translate_retry_config in google/genai/_gaos/google_genai.py defaulted the Interactions backoff to local constants (500ms initial, 8000ms max) and left jitter unset, while the rest of the SDK uses the documented HttpRetryOptions defaults from _api_client (1.0s initial, 60.0s max, 1.0 jitter). The same unset HttpRetryOptions therefore 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 way attempts already falls back to _api_client._RETRY_ATTEMPTS. The local _DEFAULT_INITIAL_INTERVAL_MS / _DEFAULT_MAX_INTERVAL_MS constants are removed; explicit per-field options still override.

Tests: two new cases in google/genai/tests/interactions/test_retry_options.py assert that unset delay options produce the shared defaults (1000ms / 60000ms / 1000ms) and that explicit values still override. The full file passes locally (13 tests).

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
@google-cla

google-cla Bot commented Nov 8, 2026

Copy link
Copy Markdown

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.

@Venkaiahbabuneelam Venkaiahbabuneelam self-assigned this Nov 9, 2026
@Venkaiahbabuneelam Venkaiahbabuneelam added the size:L Code changes between 40-100 lines label Nov 9, 2026
@Venkaiahbabuneelam

Copy link
Copy Markdown

Hi @Sun-Wukhan,
Kindly please resolve the conflicts.?
Thanks

@chrikrah chrikrah left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

@Sun-Wukhan

Copy link
Copy Markdown
Author

Thought I signed it, my bad chief. On it.

@Sun-Wukhan

Sun-Wukhan commented Nov 10, 2026 •

Copy link
Copy Markdown
Author

I signed it!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L Code changes between 40-100 lines status:awaiting user response

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interactions retries ignore the documented initial_delay and max_delay defaults

3 participants