Feat: Emit GOOGLE_GENAI_USE_ENTERPRISE from adk create and adk deploy - #286
Open
AmaadMartin wants to merge 2 commits into
Open
Conversation
added 2 commits
July 29, 2026 21:02
adk-python renamed the backend selector env var from GOOGLE_GENAI_USE_VERTEXAI to GOOGLE_GENAI_USE_ENTERPRISE. Scaffold new projects onto the current name so they no longer start life on a deprecated variable. The generated .env is only safe on the new name because the runtime now accepts it (isEnterpriseModeEnabled, this branch's base). Assert the legacy name is absent so the rename itself is pinned, and assert the previously unchecked =0 line on the API-key path.
Matches adk-python's _DOCKERFILE_TEMPLATE. createDockerFileContent had no assertion on its ENV block at all, so add one covering both the new name and the absence of the deprecated one.
This was referenced Jul 30, 2026
Fix: gitignore the .env that adk create writes so scaffolded agents cannot commit their API key
#364
Open
Open
Open
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Closes: #issue_number
Related: #issue_number
Problem: adk-python renamed the environment variable that selects the enterprise (Vertex AI) backend from
GOOGLE_GENAI_USE_VERTEXAItoGOOGLE_GENAI_USE_ENTERPRISE. adk-js still emits the deprecated name from the two places it generates config for users, so every project scaffolded withadk createand every container built byadk deploy cloud_runstarts life on a deprecated variable:dev/src/cli/cli_create.ts:167,176— the generated.envdev/src/cli/deploy/deploy_utils.ts:103— theENVline in the generated DockerfileSolution: switch both writers to
GOOGLE_GENAI_USE_ENTERPRISE, matching the reference implementation field-for-field (adk-python/src/google/adk/cli/cli_create.py:119,121andcli_deploy.py:85, both of which emit the new name only). The change is three string swaps; no new abstraction, flag, or helper.This is a stacked PR — it must not merge before BOTH read-side PRs land. See the next section.
Collision check (required, and it found something)
The read side of this feature — teaching the runtime to accept the new variable — is already split across two live sibling PRs, so none of it is reimplemented here:
feat/enterprise-mode-variant-resolutionisEnterpriseModeEnabled()+variant_utils.ts+vertex_ai_utils.tsfeat/gemini-init-params-enterprise-env-gateisEnterpriseModeEnabled()+google_llm.ts(this PR's base)This PR is the write side only and is uncontested: no open PR touches the
GOOGLE_GENAI_USE_*lines incli_create.tsordeploy_utils.ts. (#203 editscli_create.tsfor injectable gcloud defaults and #259 editscli_create_test.tsfor env hermeticity, but neither touches these lines; #279 edits the Agent Engine deploy CLI, notdeploy_utils.ts.)Merge order — both are required, for different reasons. Flipping the writers without the readers is a hard regression, so:
geminiInitParams(core/src/models/google_llm.ts:381) is what setsparams.vertexai. Without it a Vertex-mode scaffold falls into the Gemini-API branch, finds noGOOGLE_GENAI_API_KEY/GEMINI_API_KEY, and throws at construction (google_llm.ts:118-122). This PR is stacked directly on Feat: Derive the Gemini vertexai gate from GOOGLE_GENAI_USE_ENTERPRISE (adk-python parity) #267, so that one is enforced structurally.getGoogleLlmVariant()(core/src/utils/variant_utils.ts:30) still reads only the legacy name and returnsGEMINI_APIfor a new-variable scaffold. That silently changes tool behaviour —AgentToolstops attachingdeclaration.response(core/src/tools/agent_tool.ts:111, gated onapiVariant !== GEMINI_API) — andgetExpressModeApiKey()(vertex_ai_utils.ts:29) returnsundefined, breaking express mode invertex_ai_session_service.ts:87andvertex_ai_memory_bank_service.ts:129. No test fails and nothing throws.Also worth flagging to a human: #265 and #267 each independently add
isEnterpriseModeEnabled()tocore/src/utils/env_aware_utils.ts, so they conflict with each other and need reconciling before either merges. If #265 is dropped rather than merged, its two one-line call-site swaps must be folded in before this PR lands.Version-skew caveat (deliberately accepted, not fixed here)
@google/adk-devtoolswrites these files and@google/adkreads them, and they publish as separate packages. A user pairing a new devtools with an old core gets config their runtime does not understand. Foradk createthis is not reachable — the generatedpackage.json(dev/src/cli/cli_create.ts:46-61) pins no@google/adkat all, so a fresh project always resolves a current core. Foradk deploy cloud_runit is reachable, because the generated Dockerfile copies the user's ownpackage.json/package-lock.json/node_modules.I considered emitting both variable names from the Dockerfile for a deprecation window and rejected it, because it would: (a) diverge from
adk-python/src/google/adk/cli/cli_deploy.py:85, which emits onlyENV GOOGLE_GENAI_USE_ENTERPRISE=1— generated output is observable across the language boundary, so parity wins there; (b) keep writing the deprecated name this change exists to stop writing; and (c) add compatibility machinery with no defined removal trigger. This is the same exposure adk-python accepted for the same rename. Happy to revisit if a maintainer prefers the dual-write.No suppressions
No
any,@ts-expect-error,@ts-ignore,eslint-disable, or coverage-ignore was added anywhere in this diff.Testing Plan
Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes.
Unit Tests:
[x] I have added or updated unit tests for my change.
[x] All unit tests pass locally.
GitHub Actions did not run on this PR, so it was validated locally instead.
.github/workflows/validation.yamltriggers onpull_request: branches: [main], and this PR targetsfeat/gemini-init-params-enterprise-env-gate, so the workflow never fires — onlyauto-assignreported. Every job that workflow would have run was executed locally on the exact pushed commit (b1424b6c):validation.yamlstepnpx secretlint "dev/**/*"npm run buildnpx vitest run --project unit:dev dev/test/cli/cli_create_test.ts dev/test/cli/cli_deploy_cloud_run_test.tsnpm run lintnpm run format:checknpm run docs:checkThe workflow's test step is
npm run test:coverage, which runs the entire repository suite; per the contribution workflow for this change only the two directly affected test files were run rather than the full suite.npm run ts:checkreports pre-existing errors in 48 files across the test tree; the count is identical (48) on this branch and on its base, so this change introduces none. None are indev/.What the tests pin.
createDockerFileContentpreviously had no assertion at all on itsENVblock, and the=0line on the API-key path was unasserted, so both were free to regress. Each changed line now has a positive assertion (new name present) and a negative one (legacy name absent) — the negative is what actually pins the rename rather than merely the presence of the new name. No existing test was deleted, skipped, or weakened; the one existing assertion that changed (cli_create_test.ts:131) was retargeted from the old name to the new one, which is the behaviour change itself.Proof each test can fail. Every assertion was run against mutated source and confirmed to FAIL:
cli_create.ts:176→GOOGLE_GENAI_USE_VERTEXAI=1should set Vertex AI env vars if project/region providedAssertionError: expected "spy" to be called with arguments: [ StringContaining ".env", …(1) ]cli_create.ts:167→GOOGLE_GENAI_USE_VERTEXAI=0should set Google AI env vars if api key providedAssertionErroron the.envspydeploy_utils.ts:103→ENV GOOGLE_GENAI_USE_VERTEXAI=1should set the enterprise backend env var...AssertionError: expected '\nFROM node:lts-alpine…' to contain 'ENV GOOGLE_GENAI_USE_ENTERPRISE=1'generateEnvFileshould set Vertex AI env vars if project/region providedStringNotContaining "GOOGLE_GENAI_USE_VERTEXAI"— proves the negative assertion carries independent signal, since the positive one still passesshould set the enterprise backend env var...AssertionError: expected '\nFROM node:lts-alpine…' not to contain 'GOOGLE_GENAI_USE_VERTEXAI'Mutations 4 and 5 matter: without them the suite would pass a dual-write implementation, and the rename would not actually be pinned.
Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any necessary setup or configuration.
Run against a real local build, real CLI, real filesystem, no mocks:
Observed:
grep -r GOOGLE_GENAI_USE_VERTEXAI demo-vertex demo-key --exclude-dir=node_modules→ no hits.Then loading
demo-vertex/.envinto the process and constructingGeminiagainst the workspace build — the step that would have caught the regression described above:…with no deprecation warning, and with no API key present. Backward compatibility, using a
.envon the legacy name instead:Repeating the first check against the published
@google/adk(which lacks the read side) reproduces the exact regression this stack exists to prevent —Error: API key must be provided via constructor or GOOGLE_GENAI_API_KEY or GEMINI_API_KEY environment variable.— which is why the merge-order note above is not theoretical.Finally, calling the real
createDockerFileContent:Unrelated pre-existing bug found while doing this, filed separately rather than fixed here:
adk create --api_key KwritesGOOGLE_API_KEY, butgeminiInitParamsonly falls back toGOOGLE_GENAI_API_KEY/GEMINI_API_KEY(google_llm.ts:401-403), so that scaffold cannot start. It reproduces identically with the oldGOOGLE_GENAI_USE_VERTEXAI=0line, so it is not a regression from this change and is out of scope.Checklist
[x] I have read the CONTRIBUTING.md document.
[x] I have performed a self-review of my own code.
[x] I have commented my code, particularly in hard-to-understand areas.
[x] I have added tests that prove my fix is effective or that my feature works.
[x] New and existing unit tests pass locally with my changes.