-
Notifications
You must be signed in to change notification settings - Fork 184
Feat: Honor GOOGLE_GENAI_USE_ENTERPRISE in getExpressModeApiKey() (adk-python parity) #569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AmaadMartin
wants to merge
5
commits into
google:main
Choose a base branch
from
AmaadMartin:feat/express-mode-enterprise-env-parity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
919fddc
feat(utils): honor GOOGLE_GENAI_USE_ENTERPRISE in getExpressModeApiKey
02839db
test(utils): trim express-mode enterprise cases to distinct branches
f07d930
refactor: route every enterprise-mode env read through isEnterpriseMo…
b2689c2
refactor: keep the enterprise-mode sweep to env readers
2a16f3c
fix(utils): log the enterprise-mode deprecation warning only once
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GOOGLE_GENAI_USE_VERTEXAIused all over the code source, please update all the references to useisEnterpriseModeEnabledinsteadThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done — every read of
GOOGLE_GENAI_USE_VERTEXAInow goes throughisEnterpriseModeEnabled.I moved the helper out of
vertex_ai_utils.tsand exported it fromcore/src/utils/env_aware_utils.ts, right next togetBooleanEnvVar(this mirrors adk-python, whereis_enterprise_mode_enabledandis_env_enabledboth live inutils/env_utils.py). Converted call sites:core/src/utils/vertex_ai_utils.ts—getExpressModeApiKey()core/src/utils/variant_utils.ts—getGoogleLlmVariant()core/src/models/google_llm.ts—geminiInitParams(), whichApigeeLlmalso routes throughNo
GOOGLE_GENAI_USE_VERTEXAIread remains outside the helper. You were right that the first revision was incoherent: with onlygetExpressModeApiKeyconverted,GOOGLE_GENAI_USE_ENTERPRISE=truereturned an express-mode key whilegetGoogleLlmVariant()still reportedGEMINI_APIandgeminiInitParams()still setvertexai: false.Two things I did differently than a literal sweep — please push back if you disagree:
The deprecation warning is now emitted once per process.
getGoogleLlmVariant()is reached fromBaseTool.apiVarianton every request, so warning on each read would print a line per tool per request for everyone still on the legacy variable. Python'swarnings.warn(..., DeprecationWarning)is deduplicated by the default filter, so once-per-process is the parity behaviour; it costs one module-level flag, and the helper's tests reload the module (and its logger) per test so the flag cannot leak between them.I did not touch the two places that write the variable —
dev/src/cli/cli_create.ts(the.envfromadk create) anddev/src/cli/deploy/deploy_utils.ts(ENV GOOGLE_GENAI_USE_VERTEXAI=1in the generated Dockerfile). They emit rather than read, so they can't use the helper, and renaming what they emit is not backwards compatible: the generated image installs@google/adk-devtools@latestbut takes@google/adkfrom the user's copiedpackage.json/node_modules, so the container can run a core that only understands the old name — and becausegeminiInitParamsforwards the resolved value to the SDK as an explicitvertexaiflag, the SDK's ownGOOGLE_GENAI_USE_ENTERPRISEsupport can't cover for it. adk-python does emit the new name from its scaffolding, so I'm happy to follow suit — either in this PR, or as a follow-up once a release that reads the new variable is out, or by emitting both names. Your call.Tests: new cases per call site in
env_aware_utils_test.ts,variant_utils_test.ts,google_llm_test.tsandvertex_ai_utils_test.ts(13 in total, each verified to fail against the unmodifiedcore/src), including warn-once on repeated reads. The four suites that touch these variables now also clearGOOGLE_GENAI_USE_ENTERPRISEin setup — since precedence is by presence, an ambient value of any kind would otherwise flip them.