Skip to content

Commit 28499a9

Browse files
shawn-yang-googlecopybara-github
authored andcommitted
feat: GenAI SDK client - Support build options in Agent Engine GCS Deployment.
PiperOrigin-RevId: 833444035
1 parent 8d5c777 commit 28499a9

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

tests/unit/vertexai/genai/test_agent_engines.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,28 @@ def test_create_agent_engine_config_with_source_packages(
10621062
== _TEST_AGENT_ENGINE_IDENTITY_TYPE_SERVICE_ACCOUNT
10631063
)
10641064

1065+
@mock.patch.object(_agent_engines_utils, "_prepare")
1066+
@mock.patch.object(_agent_engines_utils, "_validate_extra_packages_or_raise")
1067+
def test_create_agent_engine_config_with_build_options(
1068+
self, mock_validate_extra_packages, mock_prepare
1069+
):
1070+
build_options = {"installation_scripts": ["install.sh"]}
1071+
extra_packages = ["install.sh"]
1072+
1073+
self.client.agent_engines._create_config(
1074+
mode="create",
1075+
agent=self.test_agent,
1076+
staging_bucket=_TEST_STAGING_BUCKET,
1077+
display_name=_TEST_AGENT_ENGINE_DISPLAY_NAME,
1078+
extra_packages=extra_packages,
1079+
build_options=build_options,
1080+
)
1081+
1082+
mock_validate_extra_packages.assert_called_once_with(
1083+
extra_packages=extra_packages,
1084+
build_options=build_options,
1085+
)
1086+
10651087
@mock.patch.object(_agent_engines_utils, "_prepare")
10661088
def test_update_agent_engine_config_full(self, mock_prepare):
10671089
config = self.client.agent_engines._create_config(
@@ -1598,6 +1620,7 @@ def test_create_agent_engine_with_env_vars_dict(
15981620
requirements_file=None,
15991621
agent_framework=None,
16001622
python_version=None,
1623+
build_options=None,
16011624
)
16021625
request_mock.assert_called_with(
16031626
"post",
@@ -1691,6 +1714,7 @@ def test_create_agent_engine_with_custom_service_account(
16911714
requirements_file=None,
16921715
agent_framework=None,
16931716
python_version=None,
1717+
build_options=None,
16941718
)
16951719
request_mock.assert_called_with(
16961720
"post",
@@ -1783,6 +1807,7 @@ def test_create_agent_engine_with_experimental_mode(
17831807
requirements_file=None,
17841808
agent_framework=None,
17851809
python_version=None,
1810+
build_options=None,
17861811
)
17871812
request_mock.assert_called_with(
17881813
"post",
@@ -1938,6 +1963,7 @@ def test_create_agent_engine_with_class_methods(
19381963
requirements_file=None,
19391964
agent_framework=None,
19401965
python_version=None,
1966+
build_options=None,
19411967
)
19421968
request_mock.assert_called_with(
19431969
"post",
@@ -2025,6 +2051,7 @@ def test_create_agent_engine_with_agent_framework(
20252051
agent_framework=_TEST_AGENT_FRAMEWORK,
20262052
identity_type=None,
20272053
python_version=None,
2054+
build_options=None,
20282055
)
20292056
request_mock.assert_called_with(
20302057
"post",

vertexai/_genai/agent_engines.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,7 @@ def create(
938938
requirements_file=config.requirements_file,
939939
agent_framework=config.agent_framework,
940940
python_version=config.python_version,
941+
build_options=config.build_options,
941942
)
942943
operation = self._create(config=api_config)
943944
# TODO: Use a more specific link.
@@ -1004,6 +1005,7 @@ def _create_config(
10041005
requirements_file: Optional[str] = None,
10051006
agent_framework: Optional[str] = None,
10061007
python_version: Optional[str] = None,
1008+
build_options: Optional[dict[str, list[str]]] = None,
10071009
) -> types.UpdateAgentEngineConfigDict:
10081010
import sys
10091011

@@ -1067,6 +1069,7 @@ def _create_config(
10671069
)
10681070
extra_packages = _agent_engines_utils._validate_extra_packages_or_raise(
10691071
extra_packages=extra_packages,
1072+
build_options=build_options,
10701073
)
10711074
# Prepares the Agent Engine for creation/update in Vertex AI. This
10721075
# involves packaging and uploading the artifacts for agent_engine,
@@ -1465,6 +1468,7 @@ def update(
14651468
requirements_file=config.requirements_file,
14661469
agent_framework=config.agent_framework,
14671470
python_version=config.python_version,
1471+
build_options=config.build_options,
14681472
)
14691473
operation = self._update(name=name, config=api_config)
14701474
logger.info(

vertexai/_genai/types/common.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5471,6 +5471,17 @@ class CreateAgentEngineConfig(_common.BaseModel):
54715471
Supported versions: "3.9", "3.10", "3.11", "3.12", "3.13".
54725472
""",
54735473
)
5474+
build_options: Optional[dict[str, list[str]]] = Field(
5475+
default=None,
5476+
description="""The build options for the Agent Engine.
5477+
The following keys are supported:
5478+
- installation_scripts:
5479+
Optional. The paths to the installation scripts to be
5480+
executed in the Docker image.
5481+
The scripts must be located in the `installation_scripts`
5482+
subdirectory and the path must be added to `extra_packages`.
5483+
""",
5484+
)
54745485

54755486

54765487
class CreateAgentEngineConfigDict(TypedDict, total=False):
@@ -5587,6 +5598,16 @@ class CreateAgentEngineConfigDict(TypedDict, total=False):
55875598
Supported versions: "3.9", "3.10", "3.11", "3.12", "3.13".
55885599
"""
55895600

5601+
build_options: Optional[dict[str, list[str]]]
5602+
"""The build options for the Agent Engine.
5603+
The following keys are supported:
5604+
- installation_scripts:
5605+
Optional. The paths to the installation scripts to be
5606+
executed in the Docker image.
5607+
The scripts must be located in the `installation_scripts`
5608+
subdirectory and the path must be added to `extra_packages`.
5609+
"""
5610+
55905611

55915612
CreateAgentEngineConfigOrDict = Union[
55925613
CreateAgentEngineConfig, CreateAgentEngineConfigDict
@@ -6210,6 +6231,17 @@ class UpdateAgentEngineConfig(_common.BaseModel):
62106231
Supported versions: "3.9", "3.10", "3.11", "3.12", "3.13".
62116232
""",
62126233
)
6234+
build_options: Optional[dict[str, list[str]]] = Field(
6235+
default=None,
6236+
description="""The build options for the Agent Engine.
6237+
The following keys are supported:
6238+
- installation_scripts:
6239+
Optional. The paths to the installation scripts to be
6240+
executed in the Docker image.
6241+
The scripts must be located in the `installation_scripts`
6242+
subdirectory and the path must be added to `extra_packages`.
6243+
""",
6244+
)
62136245
update_mask: Optional[str] = Field(
62146246
default=None,
62156247
description="""The update mask to apply. For the `FieldMask` definition, see
@@ -6331,6 +6363,16 @@ class UpdateAgentEngineConfigDict(TypedDict, total=False):
63316363
Supported versions: "3.9", "3.10", "3.11", "3.12", "3.13".
63326364
"""
63336365

6366+
build_options: Optional[dict[str, list[str]]]
6367+
"""The build options for the Agent Engine.
6368+
The following keys are supported:
6369+
- installation_scripts:
6370+
Optional. The paths to the installation scripts to be
6371+
executed in the Docker image.
6372+
The scripts must be located in the `installation_scripts`
6373+
subdirectory and the path must be added to `extra_packages`.
6374+
"""
6375+
63346376
update_mask: Optional[str]
63356377
"""The update mask to apply. For the `FieldMask` definition, see
63366378
https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask."""
@@ -13251,6 +13293,17 @@ class AgentEngineConfig(_common.BaseModel):
1325113293
Supported versions: "3.9", "3.10", "3.11", "3.12", "3.13".
1325213294
""",
1325313295
)
13296+
build_options: Optional[dict[str, list[str]]] = Field(
13297+
default=None,
13298+
description="""The build options for the Agent Engine.
13299+
The following keys are supported:
13300+
- installation_scripts:
13301+
Optional. The paths to the installation scripts to be
13302+
executed in the Docker image.
13303+
The scripts must be located in the `installation_scripts`
13304+
subdirectory and the path must be added to `extra_packages`.
13305+
""",
13306+
)
1325413307

1325513308

1325613309
class AgentEngineConfigDict(TypedDict, total=False):
@@ -13399,6 +13452,16 @@ class AgentEngineConfigDict(TypedDict, total=False):
1339913452
Supported versions: "3.9", "3.10", "3.11", "3.12", "3.13".
1340013453
"""
1340113454

13455+
build_options: Optional[dict[str, list[str]]]
13456+
"""The build options for the Agent Engine.
13457+
The following keys are supported:
13458+
- installation_scripts:
13459+
Optional. The paths to the installation scripts to be
13460+
executed in the Docker image.
13461+
The scripts must be located in the `installation_scripts`
13462+
subdirectory and the path must be added to `extra_packages`.
13463+
"""
13464+
1340213465

1340313466
AgentEngineConfigOrDict = Union[AgentEngineConfig, AgentEngineConfigDict]
1340413467

0 commit comments

Comments
 (0)