@@ -781,6 +781,10 @@ def set_up(self):
781781 os .environ ["GOOGLE_CLOUD_AGENT_ENGINE_LOCATION" ] = location
782782 if "GOOGLE_CLOUD_LOCATION" not in os .environ :
783783 os .environ ["GOOGLE_CLOUD_LOCATION" ] = location
784+ agent_engine_location = os .environ .get (
785+ "GOOGLE_CLOUD_AGENT_ENGINE_LOCATION" , # the runtime env var (if set)
786+ location , # the location set in the AdkApp template
787+ )
784788 express_mode_api_key = self ._tmpl_attrs .get ("express_mode_api_key" )
785789 if express_mode_api_key and not project :
786790 os .environ ["GOOGLE_API_KEY" ] = express_mode_api_key
@@ -868,7 +872,7 @@ def set_up(self):
868872 # environment variable when initializing the session service.
869873 self ._tmpl_attrs ["session_service" ] = VertexAiSessionService (
870874 project = project ,
871- location = location ,
875+ location = agent_engine_location ,
872876 agent_engine_id = os .environ .get ("GOOGLE_CLOUD_AGENT_ENGINE_ID" ),
873877 )
874878 except (ImportError , AttributeError ):
@@ -880,7 +884,7 @@ def set_up(self):
880884 # environment variable when initializing the session service.
881885 self ._tmpl_attrs ["session_service" ] = VertexAiSessionService (
882886 project = project ,
883- location = location ,
887+ location = agent_engine_location ,
884888 agent_engine_id = os .environ .get ("GOOGLE_CLOUD_AGENT_ENGINE_ID" ),
885889 )
886890
@@ -902,7 +906,7 @@ def set_up(self):
902906 # environment variable when initializing the memory service.
903907 self ._tmpl_attrs ["memory_service" ] = VertexAiMemoryBankService (
904908 project = project ,
905- location = location ,
909+ location = agent_engine_location ,
906910 agent_engine_id = os .environ .get ("GOOGLE_CLOUD_AGENT_ENGINE_ID" ),
907911 )
908912 except (ImportError , AttributeError ):
@@ -914,7 +918,7 @@ def set_up(self):
914918 # environment variable when initializing the memory service.
915919 self ._tmpl_attrs ["memory_service" ] = VertexAiMemoryBankService (
916920 project = project ,
917- location = location ,
921+ location = agent_engine_location ,
918922 agent_engine_id = os .environ .get ("GOOGLE_CLOUD_AGENT_ENGINE_ID" ),
919923 )
920924 else :
0 commit comments