adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

Pass the value of GOOGLE_CLOUD_LOCATION and GOOGLE_GENAI_USE_VERTEXAI while creating the object of Ruuner

Open naitik-parekh opened this issue 1 year ago • 5 comments

Problem description I have created an application which will be used by multiple clients. The of GOOGLE_CLOUD_LOCATION is defined as environment variable. So, the same location will be used for each client. I need to use different location for each client as per their compliance requirements. How can I change the location at runtime?

Same is the case for GOOGLE_GENAI_USE_VERTEXAI. I am using gemini api key for some clients, so I need to change the value of GOOGLE_GENAI_USE_VERTEXAI as well at runtime.

Desired solution Provide a way to pass the value for GOOGLE_GENAI_USE_VERTEXAI and GOOGLE_CLOUD_LOCATION while creating the object of google.adk.runners.Runner

Additional context I am using google-adk==1.2.1

naitik-parekh avatar Jun 18 '25 10:06 naitik-parekh

@hangfei, please can you assign this one to me? I want to take it on.

bl3ck avatar Jun 18 '25 18:06 bl3ck

Hi @bl3ck,

Please share the possible solution and tentative timeline.

naitik-parekh avatar Jun 25 '25 12:06 naitik-parekh

@naitik-parekh Thanks for getting back to me on this. Here's how I would like to go about it:

I'll extend the Runner class constructor to accept optional parameters that override environment variables for specific instances.

Proposed Solution

Add optional cloud_location and use_vertex_ai parameters to the Runner constructor with configuration precedence: constructor params → environment variables → defaults.

runner = Runner(
    agent=my_agent,
    app_name="client_app",
    session_service=session_service,
    cloud_location="europe-west1",        # Overrides GOOGLE_CLOUD_LOCATION
    use_vertex_ai=True                             # Overrides GOOGLE_GENAI_USE_VERTEXAI
)

I'll also validate the cloud_location parameter against supported Google Cloud regions to ensure compliance requirements are met.

Timeline:

  • Week 1: Core implementation and unit tests
  • Week 2: Integration testing, documentation, and PR refinement

Are there other ADK components beyond Runner that consume these environment variables directly?

bl3ck avatar Jun 28 '25 03:06 bl3ck

Hi @bl3ck ,

I have not used all the classes/methods of ADK to be able to comment where else these variables are used.

naitik-parekh avatar Jun 30 '25 07:06 naitik-parekh

Hi @naitik-parekh and thanks to everyone who participated in this thread.

We're currently doing some housekeeping on our issue tracker. Given the rapid pace of development and the number of updates since this was last active, there's a good chance this issue has been resolved in a newer version. To help us keep our backlog focused on current issues, we are closing this as stale.

If you're still facing this problem, could you please update to the very latest version of the library and confirm the issue still exists? If it does, please comment here, and we will be happy to reopen this issue and investigate further.

Thanks for your contribution and understanding!

surajksharma07 avatar Oct 08 '25 11:10 surajksharma07