diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e5347d0d..2e164fe7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,29 +1,5 @@ # Changelog -## [2.32.0](https://github.com/googleapis/python-genai/compare/v2.31.0...v2.32.0) (2026-10-21) - - -### Features - -* Add base_voice to PromptedVoice in GAOS SDK ([5488643](https://github.com/googleapis/python-genai/commit/548864370ee9c88de0bd839b619dc05bcb7085e7)) -* Add generation_output_config to GenerateContentConfig ([5c008e1](https://github.com/googleapis/python-genai/commit/5c008e14b9c9fdecbaf61eb53ad7c09f57fa5f8a)) -* Add Live API in-session context updates (`send_context_update`) and types across GenAI SDKs. ([364889a](https://github.com/googleapis/python-genai/commit/364889aafe40bfa8f3b9db847ba272d299f7d632)) -* **sdks:** Enable `fixes.openSingleValueEnumsOct2026` across all SDKs ([78f6d34](https://github.com/googleapis/python-genai/commit/78f6d3412caaaed44f99ce57be2d16d0b8c407cb)) -* Update discovery doc ([6cd176e](https://github.com/googleapis/python-genai/commit/6cd176e135a188bbb0d0f9afca520e7d6483823d)) - - -### Bug Fixes - -* Base64-encode inline bytes in Live send_tool_response ([a7bbff6](https://github.com/googleapis/python-genai/commit/a7bbff6e73fa9444802cd9a17e8c94e30341bf5d)), refs [#3022](https://github.com/googleapis/python-genai/issues/3022) -* Don't crash parsing responses with JSON objects in `Any`-typed fields ([4c1abcc](https://github.com/googleapis/python-genai/commit/4c1abccf258c9247218e66610790043893cd6950)) -* **interactions:** Sync InteractionSseEventInteractionStatus enum with InteractionStatus ([ba854b2](https://github.com/googleapis/python-genai/commit/ba854b2d29a3ff0d4758da886edabb458726b210)) - - -### Documentation - -* Publish the API reference on each release ([1d12358](https://github.com/googleapis/python-genai/commit/1d12358a1398b9a510ae8ba25dd31e746d8e9be9)) -* Transition docs workflow to GitHub Actions ([3b1256a](https://github.com/googleapis/python-genai/commit/3b1256ac5f4b8c49a469ca307ca765185184774d)) - ## [2.31.0](https://github.com/googleapis/python-genai/compare/v2.30.1...v2.31.0) (2026-10-14) diff --git a/google/genai/_api_client.py b/google/genai/_api_client.py index d972abc13..82e48973c 100644 --- a/google/genai/_api_client.py +++ b/google/genai/_api_client.py @@ -609,6 +609,11 @@ def _load_json_from_response(cls, response: Any) -> Any: ) +def _delay_or_default(value: Optional[float], default: float) -> float: + """Returns the default only when the field is unset, so 0.0 is honored.""" + return default if value is None else value + + def retry_args(options: Optional[HttpRetryOptions]) -> _common.StringDict: """Returns the retry args for the given http retry options. @@ -630,10 +635,10 @@ def retry_args(options: Optional[HttpRetryOptions]) -> _common.StringDict: or isinstance(e, _HTTPX_TRANSIENT_EXC), ) wait = tenacity.wait_exponential_jitter( - initial=options.initial_delay or _RETRY_INITIAL_DELAY, - max=options.max_delay or _RETRY_MAX_DELAY, - exp_base=options.exp_base or _RETRY_EXP_BASE, - jitter=options.jitter or _RETRY_JITTER, + initial=_delay_or_default(options.initial_delay, _RETRY_INITIAL_DELAY), + max=_delay_or_default(options.max_delay, _RETRY_MAX_DELAY), + exp_base=_delay_or_default(options.exp_base, _RETRY_EXP_BASE), + jitter=_delay_or_default(options.jitter, _RETRY_JITTER), ) return { 'stop': stop, diff --git a/google/genai/tests/client/test_retries.py b/google/genai/tests/client/test_retries.py index d02711313..2061ceb46 100644 --- a/google/genai/tests/client/test_retries.py +++ b/google/genai/tests/client/test_retries.py @@ -187,6 +187,21 @@ def test_retry_args_enabled_with_custom_values_are_not_overridden(): assert not retry.predicate(e) +def test_retry_args_explicit_zero_values_are_not_overridden(): + # A field set to 0.0 is specified, so it must reach tenacity instead of + # falling back to the default. + options = types.HttpRetryOptions( + initial_delay=0.0, max_delay=0.0, exp_base=0.0, jitter=0.0 + ) + + wait = api_client.retry_args(options)['wait'] + + assert wait.jitter == 0.0 + assert wait.initial == 0.0 + assert wait.max == 0.0 + assert wait.exp_base == 0.0 + + def test_retry_args_retries_httpx_transport_errors(): # httpx transport errors (timeouts, connect errors) bypass APIError but are # transient infrastructure failures, so the predicate must still retry them diff --git a/google/genai/version.py b/google/genai/version.py index f2db2d769..65ade1711 100644 --- a/google/genai/version.py +++ b/google/genai/version.py @@ -13,4 +13,4 @@ # limitations under the License. # -__version__ = '2.32.0' # x-release-please-version +__version__ = '2.31.0' # x-release-please-version diff --git a/pyproject.toml b/pyproject.toml index 4679764b4..a910909a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools", "wheel", "twine>=6.1.0", "packaging>=24.2", "pkginfo>= [project] name = "google-genai" -version = "2.32.0" +version = "2.31.0" description = "GenAI Python SDK" readme = "README.md" license = "Apache-2.0"