From 8d13c3a498d01f1c3618e9258baa7578b312f605 Mon Sep 17 00:00:00 2001 From: Yeesian Ng Date: Tue, 3 Feb 2026 08:16:53 -0800 Subject: [PATCH] fix: Use GOOGLE_CLOUD_AGENT_ENGINE_LOCATION env var for service locations. FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/googleapis/python-aiplatform/pull/6299 from googleapis:release-please--branches--main 08557757e994c2b4b6430922480d65be0517b41d PiperOrigin-RevId: 864886920 --- vertexai/agent_engines/templates/adk.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vertexai/agent_engines/templates/adk.py b/vertexai/agent_engines/templates/adk.py index a4349f3e02..cb27b97a31 100644 --- a/vertexai/agent_engines/templates/adk.py +++ b/vertexai/agent_engines/templates/adk.py @@ -781,6 +781,10 @@ def set_up(self): os.environ["GOOGLE_CLOUD_AGENT_ENGINE_LOCATION"] = location if "GOOGLE_CLOUD_LOCATION" not in os.environ: os.environ["GOOGLE_CLOUD_LOCATION"] = location + agent_engine_location = os.environ.get( + "GOOGLE_CLOUD_AGENT_ENGINE_LOCATION", # the runtime env var (if set) + location, # the location set in the AdkApp template + ) express_mode_api_key = self._tmpl_attrs.get("express_mode_api_key") if express_mode_api_key and not project: os.environ["GOOGLE_API_KEY"] = express_mode_api_key @@ -868,7 +872,7 @@ def set_up(self): # environment variable when initializing the session service. self._tmpl_attrs["session_service"] = VertexAiSessionService( project=project, - location=location, + location=agent_engine_location, agent_engine_id=os.environ.get("GOOGLE_CLOUD_AGENT_ENGINE_ID"), ) except (ImportError, AttributeError): @@ -880,7 +884,7 @@ def set_up(self): # environment variable when initializing the session service. self._tmpl_attrs["session_service"] = VertexAiSessionService( project=project, - location=location, + location=agent_engine_location, agent_engine_id=os.environ.get("GOOGLE_CLOUD_AGENT_ENGINE_ID"), ) @@ -902,7 +906,7 @@ def set_up(self): # environment variable when initializing the memory service. self._tmpl_attrs["memory_service"] = VertexAiMemoryBankService( project=project, - location=location, + location=agent_engine_location, agent_engine_id=os.environ.get("GOOGLE_CLOUD_AGENT_ENGINE_ID"), ) except (ImportError, AttributeError): @@ -914,7 +918,7 @@ def set_up(self): # environment variable when initializing the memory service. self._tmpl_attrs["memory_service"] = VertexAiMemoryBankService( project=project, - location=location, + location=agent_engine_location, agent_engine_id=os.environ.get("GOOGLE_CLOUD_AGENT_ENGINE_ID"), ) else: