@@ -253,8 +253,8 @@ def to_agent_engine(
253
253
temp_folder : str ,
254
254
adk_app : str ,
255
255
staging_bucket : str ,
256
- agent_engine_name : str ,
257
256
trace_to_cloud : bool ,
257
+ agent_engine_id : Optional [str ] = None ,
258
258
absolutize_imports : bool = True ,
259
259
project : Optional [str ] = None ,
260
260
region : Optional [str ] = None ,
@@ -294,9 +294,9 @@ def to_agent_engine(
294
294
project (str): Google Cloud project id.
295
295
region (str): Google Cloud region.
296
296
staging_bucket (str): The GCS bucket for staging the deployment artifacts.
297
- agent_engine_name (str): The name of the Agent Engine instance to update if
298
- it exists. Format: `projects/{project}/locations/{location}/reasoningEngines/{resource_id}`.
299
297
trace_to_cloud (bool): Whether to enable Cloud Trace.
298
+ agent_engine_id (str): The ID of the Agent Engine instance to update. If not
299
+ specified, a new Agent Engine instance will be created.
300
300
absolutize_imports (bool): Whether to absolutize imports. If True, all relative
301
301
imports will be converted to absolute import statements. Default is True.
302
302
requirements_file (str): The filepath to the `requirements.txt` file to use.
@@ -407,7 +407,7 @@ def to_agent_engine(
407
407
408
408
click .echo ('Deploying to agent engine...' )
409
409
agent_engine = agent_engines .ModuleAgent (
410
- module_name = 'agent_engine_app' ,
410
+ module_name = adk_app ,
411
411
agent_name = 'adk_app' ,
412
412
register_operations = {
413
413
'' : [
@@ -425,7 +425,7 @@ def to_agent_engine(
425
425
'async_stream' : ['async_stream_query' ],
426
426
'stream' : ['stream_query' , 'streaming_agent_run_with_events' ],
427
427
},
428
- sys_paths = [temp_folder ],
428
+ sys_paths = [temp_folder [ 1 :] ],
429
429
)
430
430
agent_config = dict (
431
431
agent_engine = agent_engine ,
@@ -436,10 +436,11 @@ def to_agent_engine(
436
436
extra_packages = [temp_folder ],
437
437
)
438
438
439
- if not agent_engine_name :
439
+ if not agent_engine_id :
440
440
agent_engines .create (** agent_config )
441
441
else :
442
- agent_engines .update (resource_name = agent_engine_name , ** agent_config )
442
+ name = f'projects/{ project } /locations/{ region } /reasoningEngines/{ agent_engine_id } '
443
+ agent_engines .update (resource_name = name , ** agent_config )
443
444
finally :
444
445
click .echo (f'Cleaning up the temp folder: { temp_folder } ' )
445
446
shutil .rmtree (temp_folder )
0 commit comments