fix(gen): restore async client with langchain-google-genai >= 4.3.7 - #1
Closed
friedrichwilken wants to merge 1 commit into
Closed
friedrichwilken wants to merge 1 commit into
friedrichwilken wants to merge 1 commit into
Conversation
friedrichwilken
force-pushed
the
fix-google-genai-async
branch
3 times, most recently
from
September 24, 2026 17:11
38f97b9 to
d6b37e2
Compare
The SDK's ChatGoogleGenerativeAI shadows the upstream `validate_environment` validator to inject the AI Core client. Since langchain-google-genai 4.3.7 that upstream validator also registers the client with a `_ClientCleanup` object which the `async_client` property and `aclose()` dereference, so every async call failed with AttributeError. Register the injected client in a validator of our own on the chat class, add a unit test covering `async_client` and `aclose()`, lift the `<4.3.7` pin introduced as a stopgap in SAP#122/SAP#129, and update the stale pin in README_sphynx.md. Refs SAP#152
friedrichwilken
force-pushed
the
fix-google-genai-async
branch
from
September 24, 2026 17:22
d6b37e2 to
0356f8d
Compare
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.
Context
Review copy on the fork before raising it upstream.
What this PR does and why it is needed
Problem: the SDK's
ChatGoogleGenerativeAIoverrides an upstream pydantic validator (validate_environment) to inject the AI Core client, and since 4.3.7 upstream also does its async setup in that validator, so the override drops it and every async call fails:Solution: do that async setup in a validator of our own. A new after-validator
_register_client_cleanuponChatGoogleGenerativeAIwraps the injected client in upstream's_ClientCleanup, which is whatasync_clientandaclose()read. The override itself has to stay because upstream overwritesself.clientunconditionally. Embeddings are untouched; upstream's embeddings have no such setup._ClientCleanupis a private upstream name. It is imported unconditionally: the pin guarantees it exists, and if upstream ever moves it the SDK fails at import time instead of on the first async call.Also: pin lifted to
langchain-google-genai~=4.4.0,uv.lockregenerated (only that package changes), stale pin inREADME_sphynx.mdupdated.Testing
test_async_client_available: assertsasync_clientresolves andaclose()completes, with a mocked proxy client. Fails on 4.4.0 without the fix, passes with it.TestAsyncGoogleGenerativeAI) not run locally (no working AI Core credentials at hand). They exercise exactly this path and run in the upstream CI integration job.