Repository navigation
fix(gemini): isolate concurrent SDK credentials per request - #190
Merged
n-papaioannou merged 2 commits intoOct 5, 2026
Merged
n-papaioannou merged 2 commits into
n-papaioannou merged 2 commits into
Conversation
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
rudycelekli
requested review from
Sebabaian,
dimneo,
n-papaioannou and
stefyi-4355
as code owners
October 5, 2026 08:59
n-papaioannou
approved these changes
Oct 5, 2026
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.
On supported Python 3.11, two concurrent Gemini calls with different API keys can both use the second caller's key. GenerativeModel resolves a process-global default client after wait_for schedules generation, so another call's genai.configure replaces the pending request's identity.
Create a native async SDK client per request, bind it to GenerativeModel's existing async-client slot before scheduling generation, and manage it with the SDK context manager. This preserves model/response conversion while isolating credentials and closing channels on success, error and cancellation. The existing GEMINI_API_KEY/GOOGLE_API_KEY fallback is preserved.
Validation:
Worked synthetic customer-support fixture: eleven calls through the real SDK model/client construction and a controlled generation method produce a selected B07 scorecard with the mock judge:
{"provider":"gemini","test_id":"B07","status":"pass","score":1.0,"evidence_count":10,"overall_score":null}The overall score is null and CLI exit is 2 because only one category was selected. This validates adapter behavior, not provider quality. Synthetic credentials only; no paid API calls.