Repository navigation
fix: address several open SDK bugs (#2937, #2938, #3007, #2991, #2995) - #1
Merged
Merged
Conversation
- types: add FinishReason.MALFORMED_RESPONSE, which the API returns (googleapis#2937). - _api_client: use `await asyncio.sleep` instead of `time.sleep` in the httpx branch of the async upload retry, so the backoff no longer blocks the event loop (googleapis#2938). - _transformers: keep annotations next to a `$ref` (e.g. a field-level `description`) when inlining the referenced definition in response_schema, instead of overwriting them with the shared model's (googleapis#3007). - _common: serialize Pydantic's deferred model build through a lock, since `defer_build=True` is not thread safe and concurrent first use could see a half-built model (googleapis#2991). - _api_client: in `__del__`, close each aiohttp session on the event loop that created it and keep strong references to the scheduled close tasks so they are not destroyed while pending (googleapis#2995). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R97bRW4GzCnhFEm2VhymSq
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R97bRW4GzCnhFEm2VhymSq
adri22235
marked this pull request as ready for review
October 2, 2026 16:19
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 the open upstream bugs in googleapis/python-genai that can be fixed in the SDK. The remaining open bugs (googleapis#3003, googleapis#2974, googleapis#2936, googleapis#2935, googleapis#2927, googleapis#2926 and googleapis#2925) are server-side, model-behavior or API-docs issues.
Changes
FinishReason.MALFORMED_RESPONSE, which the API already returns._async_upload_fdusedtime.sleepfor its retry backoff, which blocked the event loop. It now usesawait asyncio.sleep, like the aiohttp branch already does.process_schemaresolved a$ref, annotations next to it were overwritten by the referenced definition. For example, two fields of the same nested model with differentField(description=...)both ended up with the model's docstring. Now the field's own annotations win, and the model's docstring is used only when the field has no description.defer_build=Trueis not thread safe. Several threads using a model for the first time at once could see it half-built (AttributeError: ... no attribute '__pydantic_core_schema__')._common.BaseModelnow builds the model under a lock in__init__andmodel_validate*. These overrides are hidden from type checkers, so the signatures Pydantic generates are unchanged.__del__, each aiohttp session is now closed on the event loop that created it (withcall_soon_threadsafewhen that loop runs in another thread), and the scheduled close tasks are kept referenced so they are not destroyed while pending. The same change applies toAsyncHttpxClient.__del__.Testing
test_types.py,test_upload_errors.py,test_schema.py,test_common.pyandtest_client_close.py.pytest google/genai/tests/{types,common,transformers,client}: 633 passed, 6 skipped, 1 failed. The failure istest_aiohttp_retries_failed_request_retries_unsuccessfully_mtls, which fails the same way onmainwithout these changes: it gets a real 404 from the network in this sandbox.GenerateContentConfigat once, 100 separate processes): 19/100 runs failed onmain, 0/100 with this change.mainalready closes the session in that setup, and the issue was reported on 1.75.0 with Python 3.14. The change is defensive hardening, not a verified fix.🤖 Generated with Claude Code
https://claude.ai/code/session_01R97bRW4GzCnhFEm2VhymSq
Generated by Claude Code