Skip to content

Drop the .env, it's cleaner (ADK should pick up project and location from GCP metadata server) #2685

Closed

Description

@steren

Problem

When deploying ADK to Google Cloud, I must pass a .env file with these:

GOOGLE_GENAI_USE_VERTEXAI=TRUE
GOOGLE_CLOUD_PROJECT=my-project
GOOGLE_CLOUD_LOCATION=us-central1

Proposal

This should not be needed when deploying to GCP:

  • GOOGLE_GENAI_USE_VERTEXAI should be assumed to be TRUE unless an API key is provided.
  • GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION should be retrieved from the instance metadata server.

A note on instance metadata server:

Every GCP runtime exposes the same instance metadata server which allows retrieving project and location. See reference for Cloud Run. It's trivial for ADK to query it (see example Go code)

Activity

  1. added
    core[Component] This issue is related to the core interface and implementation
    on Aug 22, 2025
  2. added theissue type on Aug 22, 2025
  3. justingrayston commented on Aug 22, 2025

    @justingrayston
    1. Doesn't this assume that your agent running on Google Cloud is going to call Gemini in the same region which may not be the case
    2. You might be running multiple agent backends loadbalanced, so you may hit different CR regions based on where you are, but still call 1 vertex endpoint for Gemini

    I do agree we could have these as good standard defaults when running on Google cloud as long as we allow for override.

  4. steren commented on Aug 22, 2025

    @steren
    Author

    yes to be clear, I am only suggesting using this as a default behavior, the developer should still be able to customize project / location using .env

  5. added
    agent engine[Component] This issue is related to Vertex AI Agent Engine
    and removed
    core[Component] This issue is related to the core interface and implementation
    on Nov 6, 2025
  6. klateefa commented on Nov 25, 2025

    @klateefa

    @steren Thank you for reporting this. I understand the request is currently under review. Please keep me posted if anything else is needed. Thanks for your patience.

  7. added
    needs review[Status] The PR/issue is awaiting review from the maintainer
    on Nov 25, 2025
  8. a2105z commented on Aug 13, 2026

    @a2105z
    Contributor

    Hi — I'd like to take this one on.

    I'll add opt-in GCP metadata-server defaults for project/location (and Vertex usage) so Agent Engine / Cloud deploys don't require a .env for those values, while keeping explicit env/CLI overrides. Opening a PR shortly.

    @xuanyang15 please assign me (@a2105z) if that helps with routing — I don't have self-assign permissions on this repo.

  9. a2105z commented on Aug 13, 2026

    @a2105z
    Contributor

    PR ready for review: #6703

    Implements metadata-server defaults for unset GOOGLE_CLOUD_PROJECT / GOOGLE_CLOUD_LOCATION / enterprise-Vertex mode on GCP (explicit .env/shell still wins).

    @xuanyang15 @steren @klateefa — would appreciate a look when you have bandwidth.

  10. a2105z commented on Aug 13, 2026

    @a2105z
    Contributor

    @xuanyang15 — PR is up for your review: #6703

  11. DeanChensj commented on Oct 14, 2026

    @DeanChensj
    Collaborator

    Hi @steren, thank you for reporting this issue!

    This has been resolved by PR #6703 and merged into the main branch in commit 8d8bbd2.

    We are closing this issue as resolved. If you find that the issue persists on the latest ADK release or if this was closed in error, please feel free to reopen it or leave a comment! Thank you again for your contribution.

  12. github-actions commented on Oct 14, 2026

    @github-actions

    Are you satisfied with the resolution of your issue?
    Yes
    No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent engine[Component] This issue is related to Vertex AI Agent Engineneeds review[Status] The PR/issue is awaiting review from the maintainer

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions