@@ -506,12 +506,12 @@ def __init__(
506506 from google .cloud .aiplatform import initializer
507507
508508 adk_version = get_adk_version ()
509- if not is_version_sufficient ("1.5.0" ):
510- msg = (
511- f"Unsupported google-adk version: { adk_version } , please use "
512- "google-adk>=1.5.0 for AdkApp deployment on Agent Engine."
513- )
514- raise ValueError (msg )
509+ # if not is_version_sufficient("1.5.0"):
510+ # msg = (
511+ # f"Unsupported google-adk version: {adk_version}, please use "
512+ # "google-adk>=1.5.0 for AdkApp deployment on Agent Engine."
513+ # )
514+ # raise ValueError(msg)
515515
516516 if not agent and not app :
517517 raise ValueError ("One of `agent` or `app` must be provided." )
@@ -540,6 +540,7 @@ def __init__(
540540 "artifact_service_builder" : artifact_service_builder ,
541541 "memory_service_builder" : memory_service_builder ,
542542 "instrumentor_builder" : instrumentor_builder ,
543+ "express_mode_api_key" : initializer .global_config .api_key ,
543544 }
544545
545546 async def _init_session (
@@ -683,9 +684,14 @@ def set_up(self):
683684
684685 os .environ ["GOOGLE_GENAI_USE_VERTEXAI" ] = "1"
685686 project = self ._tmpl_attrs .get ("project" )
686- os .environ ["GOOGLE_CLOUD_PROJECT" ] = project
687+ if project :
688+ os .environ ["GOOGLE_CLOUD_PROJECT" ] = project
687689 location = self ._tmpl_attrs .get ("location" )
688- os .environ ["GOOGLE_CLOUD_LOCATION" ] = location
690+ if location :
691+ os .environ ["GOOGLE_CLOUD_LOCATION" ] = location
692+ express_mode_api_key = self ._tmpl_attrs .get ("express_mode_api_key" )
693+ if express_mode_api_key and not project and not location :
694+ os .environ ["GOOGLE_API_KEY" ] = express_mode_api_key
689695
690696 # Disable content capture in custom ADK spans unless user enabled
691697 # tracing explicitly with the old flag
@@ -769,21 +775,37 @@ def tracing_enabled() -> bool:
769775 VertexAiSessionService ,
770776 )
771777
778+ # if is_version_sufficient("1.18.0"):
772779 self ._tmpl_attrs ["session_service" ] = VertexAiSessionService (
773780 project = project ,
774781 location = location ,
775782 agent_engine_id = os .environ .get ("GOOGLE_CLOUD_AGENT_ENGINE_ID" ),
783+ express_mode_api_key = os .environ .get ("GOOGLE_API_KEY" ),
776784 )
785+ # else:
786+ # self._tmpl_attrs["session_service"] = VertexAiSessionService(
787+ # project=project,
788+ # location=location,
789+ # agent_engine_id=os.environ.get("GOOGLE_CLOUD_AGENT_ENGINE_ID"),
790+ # )
777791 except (ImportError , AttributeError ):
778792 from google .adk .sessions .vertex_ai_session_service_g3 import (
779793 VertexAiSessionService ,
780794 )
781795
796+ # if is_version_sufficient("1.18.0"):
782797 self ._tmpl_attrs ["session_service" ] = VertexAiSessionService (
783798 project = project ,
784799 location = location ,
785800 agent_engine_id = os .environ .get ("GOOGLE_CLOUD_AGENT_ENGINE_ID" ),
801+ express_mode_api_key = os .environ .get ("GOOGLE_API_KEY" ),
786802 )
803+ # else:
804+ # self._tmpl_attrs["session_service"] = VertexAiSessionService(
805+ # project=project,
806+ # location=location,
807+ # agent_engine_id=os.environ.get("GOOGLE_CLOUD_AGENT_ENGINE_ID"),
808+ # )
787809
788810 else :
789811 self ._tmpl_attrs ["session_service" ] = InMemorySessionService ()
@@ -799,11 +821,19 @@ def tracing_enabled() -> bool:
799821 VertexAiMemoryBankService ,
800822 )
801823
824+ # if is_version_sufficient("1.18.0"):
802825 self ._tmpl_attrs ["memory_service" ] = VertexAiMemoryBankService (
803826 project = project ,
804827 location = location ,
805828 agent_engine_id = os .environ .get ("GOOGLE_CLOUD_AGENT_ENGINE_ID" ),
829+ express_mode_api_key = os .environ .get ("GOOGLE_API_KEY" ),
806830 )
831+ # else:
832+ # self._tmpl_attrs["memory_service"] = VertexAiMemoryBankService(
833+ # project=project,
834+ # location=location,
835+ # agent_engine_id=os.environ.get("GOOGLE_CLOUD_AGENT_ENGINE_ID"),
836+ # )
807837 except (ImportError , AttributeError ):
808838 # TODO(ysian): Handle this via _g3 import for google3.
809839 pass
0 commit comments