From 2cafa031744dce686a498916bdde5d76232bb8cb Mon Sep 17 00:00:00 2001 From: A Vertex SDK engineer Date: Fri, 6 Mar 2026 07:53:10 -0800 Subject: [PATCH] feat: Add SDK method async_query to support >8 hour processing of queries. PiperOrigin-RevId: 879636016 --- .../unit/vertexai/genai/test_agent_engines.py | 50 + vertexai/_genai/agent_engines.py | 240 +++ vertexai/_genai/types/__init__.py | 94 +- vertexai/_genai/types/common.py | 1636 +++++++++-------- 4 files changed, 1191 insertions(+), 829 deletions(-) diff --git a/tests/unit/vertexai/genai/test_agent_engines.py b/tests/unit/vertexai/genai/test_agent_engines.py index f1b31590b7..cb7feeb97d 100644 --- a/tests/unit/vertexai/genai/test_agent_engines.py +++ b/tests/unit/vertexai/genai/test_agent_engines.py @@ -2866,6 +2866,56 @@ def test_query_agent_engine(self): None, ) + def test_async_query_agent_engine(self): + with mock.patch.object( + self.client.agent_engines._api_client, "request" + ) as request_mock: + request_mock.return_value = genai_types.HttpResponse(body="") + with mock.patch( + "google.cloud.storage.Client" + ) as mock_storage_client, mock.patch.object( + self.client.agent_engines, "_get" + ) as get_mock: + # Mock the GCS bucket and blob so we don't actually try to use GCS + mock_bucket = mock.Mock() + mock_bucket.exists.return_value = False + mock_blob = mock.Mock() + mock_blob.exists.return_value = False + mock_bucket.blob.return_value = mock_blob + mock_storage_client.return_value.bucket.return_value = mock_bucket + + # Mock _get to return a dummy resource + get_mock.return_value = _genai_types.ReasoningEngine( + name=_TEST_AGENT_ENGINE_RESOURCE_NAME, + spec=_genai_types.ReasoningEngineSpec(), + ) + + self.client.agent_engines.async_query( + name=_TEST_AGENT_ENGINE_RESOURCE_NAME, + config={ + "query": _TEST_QUERY_PROMPT, + "input_gcs_uri": "gs://my-input-bucket/input.json", + "output_gcs_uri": "gs://my-output-bucket/output.json", + }, + ) + + # Verify bucket creation + assert mock_bucket.create.call_count == 2 + # Verify file upload + mock_blob.upload_from_string.assert_called_once_with(_TEST_QUERY_PROMPT) + + request_mock.assert_called_with( + "post", + f"{_TEST_AGENT_ENGINE_RESOURCE_NAME}:asyncQuery", + { + "_url": {"name": _TEST_AGENT_ENGINE_RESOURCE_NAME}, + "query": _TEST_QUERY_PROMPT, + "inputGcsUri": "gs://my-input-bucket/input.json", + "outputGcsUri": "gs://my-output-bucket/output.json", + }, + None, + ) + def test_query_agent_engine_async(self): agent = self.client.agent_engines._register_api_methods( agent_engine=_genai_types.AgentEngine( diff --git a/vertexai/_genai/agent_engines.py b/vertexai/_genai/agent_engines.py index 819ad034d9..ba06ab38ed 100644 --- a/vertexai/_genai/agent_engines.py +++ b/vertexai/_genai/agent_engines.py @@ -49,6 +49,44 @@ logger.setLevel(logging.INFO) +def _AsyncQueryAgentEngineConfig_to_vertex( + from_object: Union[dict[str, Any], object], + parent_object: Optional[dict[str, Any]] = None, +) -> dict[str, Any]: + to_object: dict[str, Any] = {} + + if getv(from_object, ["query"]) is not None: + setv(parent_object, ["query"], getv(from_object, ["query"])) + + if getv(from_object, ["input_gcs_uri"]) is not None: + setv(parent_object, ["inputGcsUri"], getv(from_object, ["input_gcs_uri"])) + + if getv(from_object, ["output_gcs_uri"]) is not None: + setv(parent_object, ["outputGcsUri"], getv(from_object, ["output_gcs_uri"])) + + return to_object + + +def _AsyncQueryAgentEngineRequestParameters_to_vertex( + from_object: Union[dict[str, Any], object], + parent_object: Optional[dict[str, Any]] = None, +) -> dict[str, Any]: + to_object: dict[str, Any] = {} + if getv(from_object, ["name"]) is not None: + setv(to_object, ["_url", "name"], getv(from_object, ["name"])) + + if getv(from_object, ["config"]) is not None: + setv( + to_object, + ["config"], + _AsyncQueryAgentEngineConfig_to_vertex( + getv(from_object, ["config"]), to_object + ), + ) + + return to_object + + def _CreateAgentEngineConfig_to_vertex( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -337,6 +375,61 @@ def _UpdateAgentEngineRequestParameters_to_vertex( class AgentEngines(_api_module.BaseModule): + def _async_query( + self, + *, + name: str, + config: Optional[types.AsyncQueryAgentEngineConfigOrDict] = None, + ) -> types.AgentEngineOperation: + """ + Query an Agent Engine asynchronously. + """ + + parameter_model = types._AsyncQueryAgentEngineRequestParameters( + name=name, + config=config, + ) + + request_url_dict: Optional[dict[str, str]] + if not self._api_client.vertexai: + raise ValueError("This method is only supported in the Vertex AI client.") + else: + request_dict = _AsyncQueryAgentEngineRequestParameters_to_vertex( + parameter_model + ) + request_url_dict = request_dict.get("_url") + if request_url_dict: + path = "{name}:asyncQuery".format_map(request_url_dict) + else: + path = "{name}:asyncQuery" + + query_params = request_dict.get("_query") + if query_params: + path = f"{path}?{urlencode(query_params)}" + # TODO: remove the hack that pops config. + request_dict.pop("config", None) + + http_options: Optional[types.HttpOptions] = None + if ( + parameter_model.config is not None + and parameter_model.config.http_options is not None + ): + http_options = parameter_model.config.http_options + + request_dict = _common.convert_to_dict(request_dict) + request_dict = _common.encode_unserializable_types(request_dict) + + response = self._api_client.request("post", path, request_dict, http_options) + + response_dict = {} if not response.body else json.loads(response.body) + + return_value = types.AgentEngineOperation._from_response( + response=response_dict, kwargs=parameter_model.model_dump() + ) + + self._api_client._verify_response(return_value) + return return_value + def _create( self, *, config: Optional[types.CreateAgentEngineConfigOrDict] = None ) -> types.AgentEngineOperation: @@ -795,6 +888,96 @@ def _is_lightweight_creation( return False return True + def async_query( + self, + *, + name: str, + config: Optional[types.AsyncQueryAgentEngineConfigOrDict] = None, + ) -> types.AgentEngineOperation: + """Queries an agent engine asynchronously. + + Args: + name (str): + Required. A fully-qualified resource name or ID. + config (AsyncQueryAgentEngineConfigOrDict): + Optional. The configuration for the async query. If not provided, + the default configuration will be used. This can be used to specify + the following fields: + - query: The query to send to the agent engine. + - input_gcs_uri: The GCS URI of the input file to use for the query. + - output_gcs_uri: The GCS URI of the output file to store the results of the query. + """ + from google.cloud import storage # type: ignore[attr-defined] + + if config is None: + config = types.AsyncQueryAgentEngineConfig() + elif isinstance(config, dict): + config = types.AsyncQueryAgentEngineConfig(**config) + + api_resource = self._get(name=name) + + # Extract default GCS URIs from ReasoningEngine deployment spec env if needed + default_input_gcs_uri = None + default_output_gcs_uri = None + + if ( + api_resource.spec + and api_resource.spec.deployment_spec + and api_resource.spec.deployment_spec.env + ): + for env_var in api_resource.spec.deployment_spec.env: + if env_var.name == "INPUT_GCS_URI": + default_input_gcs_uri = env_var.value + elif env_var.name == "OUTPUT_GCS_URI": + default_output_gcs_uri = env_var.value + + storage_client = storage.Client() + + # Set up input_gcs_uri + input_gcs_uri = config.input_gcs_uri + if not input_gcs_uri: + if not default_input_gcs_uri: + raise ValueError( + "Could not determine a default GCS bucket for `input_gcs_uri` from the agent engine configuration. Please specify `input_gcs_uri`." + ) + input_gcs_uri = default_input_gcs_uri + config.input_gcs_uri = input_gcs_uri + + # Handle creating the bucket if it does not exist + bucket_name = input_gcs_uri.replace("gs://", "").split("/")[0] + bucket = storage_client.bucket(bucket_name) + + if not bucket.exists(): + bucket.create() + + if config.query: + blob_name = input_gcs_uri.replace(f"gs://{bucket_name}/", "") + blob = bucket.blob(blob_name) + if blob.exists(): + logger.warning(f"Overwriting existing file at {input_gcs_uri}") + blob.upload_from_string(config.query) + + # Set up output_gcs_uri + output_gcs_uri = config.output_gcs_uri + if not output_gcs_uri: + if not default_output_gcs_uri: + raise ValueError( + "Could not determine a default GCS bucket for `output_gcs_uri` from the agent engine configuration. Please specify `output_gcs_uri`." + ) + output_gcs_uri = default_output_gcs_uri + config.output_gcs_uri = output_gcs_uri + + output_bucket_name = output_gcs_uri.replace("gs://", "").split("/")[0] + output_bucket = storage_client.bucket(output_bucket_name) + if not output_bucket.exists(): + output_bucket.create() + + # Set query to None before it goes back to the server + config.query = None + + # Proceed with sending the async query via the auto-generated method + return self._async_query(name=name, config=config) + def get( self, *, @@ -2055,6 +2238,63 @@ def list_session_events( class AsyncAgentEngines(_api_module.BaseModule): + async def _async_query( + self, + *, + name: str, + config: Optional[types.AsyncQueryAgentEngineConfigOrDict] = None, + ) -> types.AgentEngineOperation: + """ + Query an Agent Engine asynchronously. + """ + + parameter_model = types._AsyncQueryAgentEngineRequestParameters( + name=name, + config=config, + ) + + request_url_dict: Optional[dict[str, str]] + if not self._api_client.vertexai: + raise ValueError("This method is only supported in the Vertex AI client.") + else: + request_dict = _AsyncQueryAgentEngineRequestParameters_to_vertex( + parameter_model + ) + request_url_dict = request_dict.get("_url") + if request_url_dict: + path = "{name}:asyncQuery".format_map(request_url_dict) + else: + path = "{name}:asyncQuery" + + query_params = request_dict.get("_query") + if query_params: + path = f"{path}?{urlencode(query_params)}" + # TODO: remove the hack that pops config. + request_dict.pop("config", None) + + http_options: Optional[types.HttpOptions] = None + if ( + parameter_model.config is not None + and parameter_model.config.http_options is not None + ): + http_options = parameter_model.config.http_options + + request_dict = _common.convert_to_dict(request_dict) + request_dict = _common.encode_unserializable_types(request_dict) + + response = await self._api_client.async_request( + "post", path, request_dict, http_options + ) + + response_dict = {} if not response.body else json.loads(response.body) + + return_value = types.AgentEngineOperation._from_response( + response=response_dict, kwargs=parameter_model.model_dump() + ) + + self._api_client._verify_response(return_value) + return return_value + async def _create( self, *, config: Optional[types.CreateAgentEngineConfigOrDict] = None ) -> types.AgentEngineOperation: diff --git a/vertexai/_genai/types/__init__.py b/vertexai/_genai/types/__init__.py index e6bdc09cad..f859b62df2 100644 --- a/vertexai/_genai/types/__init__.py +++ b/vertexai/_genai/types/__init__.py @@ -26,6 +26,7 @@ from .common import _AppendAgentEngineTaskEventRequestParameters from .common import _AssembleDatasetParameters from .common import _AssessDatasetParameters +from .common import _AsyncQueryAgentEngineRequestParameters from .common import _CreateAgentEngineMemoryRequestParameters from .common import _CreateAgentEngineRequestParameters from .common import _CreateAgentEngineSandboxRequestParameters @@ -158,6 +159,9 @@ from .common import AssessDatasetConfig from .common import AssessDatasetConfigDict from .common import AssessDatasetConfigOrDict +from .common import AsyncQueryAgentEngineConfig +from .common import AsyncQueryAgentEngineConfigDict +from .common import AsyncQueryAgentEngineConfigOrDict from .common import BatchPredictionResourceUsageAssessmentConfig from .common import BatchPredictionResourceUsageAssessmentConfigDict from .common import BatchPredictionResourceUsageAssessmentConfigOrDict @@ -1646,45 +1650,9 @@ "VertexBaseConfig", "VertexBaseConfigDict", "VertexBaseConfigOrDict", - "SecretRef", - "SecretRefDict", - "SecretRefOrDict", - "SecretEnvVar", - "SecretEnvVarDict", - "SecretEnvVarOrDict", - "ReasoningEngineSpecDeploymentSpec", - "ReasoningEngineSpecDeploymentSpecDict", - "ReasoningEngineSpecDeploymentSpecOrDict", - "ReasoningEngineSpecPackageSpec", - "ReasoningEngineSpecPackageSpecDict", - "ReasoningEngineSpecPackageSpecOrDict", - "ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfig", - "ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfigDict", - "ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfigOrDict", - "ReasoningEngineSpecSourceCodeSpecInlineSource", - "ReasoningEngineSpecSourceCodeSpecInlineSourceDict", - "ReasoningEngineSpecSourceCodeSpecInlineSourceOrDict", - "ReasoningEngineSpecSourceCodeSpecAgentConfigSource", - "ReasoningEngineSpecSourceCodeSpecAgentConfigSourceDict", - "ReasoningEngineSpecSourceCodeSpecAgentConfigSourceOrDict", - "ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfig", - "ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfigDict", - "ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfigOrDict", - "ReasoningEngineSpecSourceCodeSpecDeveloperConnectSource", - "ReasoningEngineSpecSourceCodeSpecDeveloperConnectSourceDict", - "ReasoningEngineSpecSourceCodeSpecDeveloperConnectSourceOrDict", - "ReasoningEngineSpecSourceCodeSpecImageSpec", - "ReasoningEngineSpecSourceCodeSpecImageSpecDict", - "ReasoningEngineSpecSourceCodeSpecImageSpecOrDict", - "ReasoningEngineSpecSourceCodeSpecPythonSpec", - "ReasoningEngineSpecSourceCodeSpecPythonSpecDict", - "ReasoningEngineSpecSourceCodeSpecPythonSpecOrDict", - "ReasoningEngineSpecSourceCodeSpec", - "ReasoningEngineSpecSourceCodeSpecDict", - "ReasoningEngineSpecSourceCodeSpecOrDict", - "ReasoningEngineSpec", - "ReasoningEngineSpecDict", - "ReasoningEngineSpecOrDict", + "AsyncQueryAgentEngineConfig", + "AsyncQueryAgentEngineConfigDict", + "AsyncQueryAgentEngineConfigOrDict", "MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEvent", "MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEventDict", "MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEventOrDict", @@ -1730,15 +1698,54 @@ "ReasoningEngineContextSpec", "ReasoningEngineContextSpecDict", "ReasoningEngineContextSpecOrDict", - "CreateAgentEngineConfig", - "CreateAgentEngineConfigDict", - "CreateAgentEngineConfigOrDict", + "SecretRef", + "SecretRefDict", + "SecretRefOrDict", + "SecretEnvVar", + "SecretEnvVarDict", + "SecretEnvVarOrDict", + "ReasoningEngineSpecDeploymentSpec", + "ReasoningEngineSpecDeploymentSpecDict", + "ReasoningEngineSpecDeploymentSpecOrDict", + "ReasoningEngineSpecPackageSpec", + "ReasoningEngineSpecPackageSpecDict", + "ReasoningEngineSpecPackageSpecOrDict", + "ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfig", + "ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfigDict", + "ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfigOrDict", + "ReasoningEngineSpecSourceCodeSpecInlineSource", + "ReasoningEngineSpecSourceCodeSpecInlineSourceDict", + "ReasoningEngineSpecSourceCodeSpecInlineSourceOrDict", + "ReasoningEngineSpecSourceCodeSpecAgentConfigSource", + "ReasoningEngineSpecSourceCodeSpecAgentConfigSourceDict", + "ReasoningEngineSpecSourceCodeSpecAgentConfigSourceOrDict", + "ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfig", + "ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfigDict", + "ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfigOrDict", + "ReasoningEngineSpecSourceCodeSpecDeveloperConnectSource", + "ReasoningEngineSpecSourceCodeSpecDeveloperConnectSourceDict", + "ReasoningEngineSpecSourceCodeSpecDeveloperConnectSourceOrDict", + "ReasoningEngineSpecSourceCodeSpecImageSpec", + "ReasoningEngineSpecSourceCodeSpecImageSpecDict", + "ReasoningEngineSpecSourceCodeSpecImageSpecOrDict", + "ReasoningEngineSpecSourceCodeSpecPythonSpec", + "ReasoningEngineSpecSourceCodeSpecPythonSpecDict", + "ReasoningEngineSpecSourceCodeSpecPythonSpecOrDict", + "ReasoningEngineSpecSourceCodeSpec", + "ReasoningEngineSpecSourceCodeSpecDict", + "ReasoningEngineSpecSourceCodeSpecOrDict", + "ReasoningEngineSpec", + "ReasoningEngineSpecDict", + "ReasoningEngineSpecOrDict", "ReasoningEngine", "ReasoningEngineDict", "ReasoningEngineOrDict", "AgentEngineOperation", "AgentEngineOperationDict", "AgentEngineOperationOrDict", + "CreateAgentEngineConfig", + "CreateAgentEngineConfigDict", + "CreateAgentEngineConfigOrDict", "DeleteAgentEngineConfig", "DeleteAgentEngineConfigDict", "DeleteAgentEngineConfigOrDict", @@ -2225,9 +2232,9 @@ "AcceleratorType", "Type", "JobState", + "ManagedTopicEnum", "IdentityType", "AgentServerMode", - "ManagedTopicEnum", "Operator", "MachineConfig", "Framework", @@ -2278,6 +2285,7 @@ "_OptimizeRequestParameters", "_CustomJobParameters", "_GetCustomJobParameters", + "_AsyncQueryAgentEngineRequestParameters", "_CreateAgentEngineRequestParameters", "_DeleteAgentEngineRequestParameters", "_GetAgentEngineRequestParameters", diff --git a/vertexai/_genai/types/common.py b/vertexai/_genai/types/common.py index a8b765de01..c9db2cd092 100644 --- a/vertexai/_genai/types/common.py +++ b/vertexai/_genai/types/common.py @@ -321,6 +321,21 @@ class JobState(_common.CaseInSensitiveEnum): """The job is partially succeeded, some results may be missing due to errors.""" +class ManagedTopicEnum(_common.CaseInSensitiveEnum): + """The managed memory topic.""" + + MANAGED_TOPIC_ENUM_UNSPECIFIED = "MANAGED_TOPIC_ENUM_UNSPECIFIED" + """Unspecified topic. This value should not be used.""" + USER_PERSONAL_INFO = "USER_PERSONAL_INFO" + """Significant personal information about the User like first names, relationships, hobbies, important dates.""" + USER_PREFERENCES = "USER_PREFERENCES" + """Stated or implied likes, dislikes, preferred styles, or patterns.""" + KEY_CONVERSATION_DETAILS = "KEY_CONVERSATION_DETAILS" + """Important milestones or conclusions within the dialogue.""" + EXPLICIT_INSTRUCTIONS = "EXPLICIT_INSTRUCTIONS" + """Information that the user explicitly requested to remember or forget.""" + + class IdentityType(_common.CaseInSensitiveEnum): """The identity type to use for the Reasoning Engine. If not specified, the `service_account` field will be used if set, otherwise the default Vertex AI Reasoning Engine Service Agent in the project will be used.""" @@ -343,21 +358,6 @@ class AgentServerMode(_common.CaseInSensitiveEnum): """Experimental agent server mode. This mode contains experimental features.""" -class ManagedTopicEnum(_common.CaseInSensitiveEnum): - """The managed memory topic.""" - - MANAGED_TOPIC_ENUM_UNSPECIFIED = "MANAGED_TOPIC_ENUM_UNSPECIFIED" - """Unspecified topic. This value should not be used.""" - USER_PERSONAL_INFO = "USER_PERSONAL_INFO" - """Significant personal information about the User like first names, relationships, hobbies, important dates.""" - USER_PREFERENCES = "USER_PREFERENCES" - """Stated or implied likes, dislikes, preferred styles, or patterns.""" - KEY_CONVERSATION_DETAILS = "KEY_CONVERSATION_DETAILS" - """Important milestones or conclusions within the dialogue.""" - EXPLICIT_INSTRUCTIONS = "EXPLICIT_INSTRUCTIONS" - """Information that the user explicitly requested to remember or forget.""" - - class Operator(_common.CaseInSensitiveEnum): """Operator to apply to the filter. If not set, then EQUAL will be used.""" @@ -6417,1004 +6417,1194 @@ class _GetCustomJobParametersDict(TypedDict, total=False): ] -class SecretRef(_common.BaseModel): - """Reference to a secret stored in the Cloud Secret Manager that will provide the value for this environment variable.""" +class AsyncQueryAgentEngineConfig(_common.BaseModel): + """Config for async querying agent engines.""" - secret: Optional[str] = Field( - default=None, - description="""Required. The name of the secret in Cloud Secret Manager. Format: {secret_name}.""", + http_options: Optional[genai_types.HttpOptions] = Field( + default=None, description="""Used to override HTTP request options.""" ) - version: Optional[str] = Field( - default=None, - description="""The Cloud Secret Manager secret version. Can be 'latest' for the latest version, an integer for a specific version, or a version alias.""", + query: Optional[str] = Field( + default=None, description="""The query to send to the agent engine.""" + ) + input_gcs_uri: Optional[str] = Field( + default=None, description="""The GCS URI of the input file.""" + ) + output_gcs_uri: Optional[str] = Field( + default=None, description="""The GCS URI of the output file.""" ) -class SecretRefDict(TypedDict, total=False): - """Reference to a secret stored in the Cloud Secret Manager that will provide the value for this environment variable.""" +class AsyncQueryAgentEngineConfigDict(TypedDict, total=False): + """Config for async querying agent engines.""" - secret: Optional[str] - """Required. The name of the secret in Cloud Secret Manager. Format: {secret_name}.""" + http_options: Optional[genai_types.HttpOptionsDict] + """Used to override HTTP request options.""" - version: Optional[str] - """The Cloud Secret Manager secret version. Can be 'latest' for the latest version, an integer for a specific version, or a version alias.""" + query: Optional[str] + """The query to send to the agent engine.""" + input_gcs_uri: Optional[str] + """The GCS URI of the input file.""" -SecretRefOrDict = Union[SecretRef, SecretRefDict] + output_gcs_uri: Optional[str] + """The GCS URI of the output file.""" -class SecretEnvVar(_common.BaseModel): - """Represents an environment variable where the value is a secret in Cloud Secret Manager.""" +AsyncQueryAgentEngineConfigOrDict = Union[ + AsyncQueryAgentEngineConfig, AsyncQueryAgentEngineConfigDict +] + + +class _AsyncQueryAgentEngineRequestParameters(_common.BaseModel): + """Parameters for async querying agent engines.""" name: Optional[str] = Field( - default=None, - description="""Required. Name of the secret environment variable.""", + default=None, description="""Name of the agent engine.""" ) - secret_ref: Optional[SecretRef] = Field( - default=None, - description="""Required. Reference to a secret stored in the Cloud Secret Manager that will provide the value for this environment variable.""", + config: Optional[AsyncQueryAgentEngineConfig] = Field( + default=None, description="""""" ) -class SecretEnvVarDict(TypedDict, total=False): - """Represents an environment variable where the value is a secret in Cloud Secret Manager.""" +class _AsyncQueryAgentEngineRequestParametersDict(TypedDict, total=False): + """Parameters for async querying agent engines.""" name: Optional[str] - """Required. Name of the secret environment variable.""" + """Name of the agent engine.""" - secret_ref: Optional[SecretRefDict] - """Required. Reference to a secret stored in the Cloud Secret Manager that will provide the value for this environment variable.""" + config: Optional[AsyncQueryAgentEngineConfigDict] + """""" -SecretEnvVarOrDict = Union[SecretEnvVar, SecretEnvVarDict] +_AsyncQueryAgentEngineRequestParametersOrDict = Union[ + _AsyncQueryAgentEngineRequestParameters, _AsyncQueryAgentEngineRequestParametersDict +] -class ReasoningEngineSpecDeploymentSpec(_common.BaseModel): - """The specification of a Reasoning Engine deployment.""" +class MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEvent( + _common.BaseModel +): + """The conversation source event for generating memories.""" - agent_server_mode: Optional[AgentServerMode] = Field( - default=None, description="""The agent server mode.""" - ) - container_concurrency: Optional[int] = Field( - default=None, - description="""Optional. Concurrency for each container and agent server. Recommended value: 2 * cpu + 1. Defaults to 9.""", - ) - env: Optional[list[EnvVar]] = Field( - default=None, - description="""Optional. Environment variables to be set with the Reasoning Engine deployment. The environment variables can be updated through the UpdateReasoningEngine API.""", - ) - max_instances: Optional[int] = Field( - default=None, - description="""Optional. The maximum number of application instances that can be launched to handle increased traffic. Defaults to 100. Range: [1, 1000]. If VPC-SC or PSC-I is enabled, the acceptable range is [1, 100].""", - ) - min_instances: Optional[int] = Field( - default=None, - description="""Optional. The minimum number of application instances that will be kept running at all times. Defaults to 1. Range: [0, 10].""", - ) - psc_interface_config: Optional[PscInterfaceConfig] = Field( - default=None, description="""Optional. Configuration for PSC-I.""" - ) - resource_limits: Optional[dict[str, str]] = Field( - default=None, - description="""Optional. Resource limits for each container. Only 'cpu' and 'memory' keys are supported. Defaults to {"cpu": "4", "memory": "4Gi"}. * The only supported values for CPU are '1', '2', '4', '6' and '8'. For more information, go to https://cloud.google.com/run/docs/configuring/cpu. * The only supported values for memory are '1Gi', '2Gi', ... '32 Gi'. * For required cpu on different memory values, go to https://cloud.google.com/run/docs/configuring/memory-limits""", - ) - secret_env: Optional[list[SecretEnvVar]] = Field( - default=None, - description="""Optional. Environment variables where the value is a secret in Cloud Secret Manager. To use this feature, add 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) to AI Platform Reasoning Engine Service Agent.""", + content: Optional[genai_types.Content] = Field( + default=None, description="""Required. The content of the event.""" ) -class ReasoningEngineSpecDeploymentSpecDict(TypedDict, total=False): - """The specification of a Reasoning Engine deployment.""" +class MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEventDict( + TypedDict, total=False +): + """The conversation source event for generating memories.""" - agent_server_mode: Optional[AgentServerMode] - """The agent server mode.""" + content: Optional[genai_types.ContentDict] + """Required. The content of the event.""" - container_concurrency: Optional[int] - """Optional. Concurrency for each container and agent server. Recommended value: 2 * cpu + 1. Defaults to 9.""" - env: Optional[list[EnvVarDict]] - """Optional. Environment variables to be set with the Reasoning Engine deployment. The environment variables can be updated through the UpdateReasoningEngine API.""" +MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEventOrDict = ( + Union[ + MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEvent, + MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEventDict, + ] +) - max_instances: Optional[int] - """Optional. The maximum number of application instances that can be launched to handle increased traffic. Defaults to 100. Range: [1, 1000]. If VPC-SC or PSC-I is enabled, the acceptable range is [1, 100].""" - min_instances: Optional[int] - """Optional. The minimum number of application instances that will be kept running at all times. Defaults to 1. Range: [0, 10].""" +class MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSource( + _common.BaseModel +): + """A conversation source for the example. This is similar to `DirectContentsSource`.""" - psc_interface_config: Optional[PscInterfaceConfigDict] - """Optional. Configuration for PSC-I.""" + events: Optional[ + list[ + MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEvent + ] + ] = Field( + default=None, + description="""Optional. The input conversation events for the example.""", + ) - resource_limits: Optional[dict[str, str]] - """Optional. Resource limits for each container. Only 'cpu' and 'memory' keys are supported. Defaults to {"cpu": "4", "memory": "4Gi"}. * The only supported values for CPU are '1', '2', '4', '6' and '8'. For more information, go to https://cloud.google.com/run/docs/configuring/cpu. * The only supported values for memory are '1Gi', '2Gi', ... '32 Gi'. * For required cpu on different memory values, go to https://cloud.google.com/run/docs/configuring/memory-limits""" - secret_env: Optional[list[SecretEnvVarDict]] - """Optional. Environment variables where the value is a secret in Cloud Secret Manager. To use this feature, add 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) to AI Platform Reasoning Engine Service Agent.""" +class MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceDict( + TypedDict, total=False +): + """A conversation source for the example. This is similar to `DirectContentsSource`.""" + + events: Optional[ + list[ + MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEventDict + ] + ] + """Optional. The input conversation events for the example.""" -ReasoningEngineSpecDeploymentSpecOrDict = Union[ - ReasoningEngineSpecDeploymentSpec, ReasoningEngineSpecDeploymentSpecDict +MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceOrDict = Union[ + MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSource, + MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceDict, ] -class ReasoningEngineSpecPackageSpec(_common.BaseModel): - """User-provided package specification, containing pickled object and package requirements.""" +class MemoryTopicId(_common.BaseModel): + """The topic ID for a memory.""" - dependency_files_gcs_uri: Optional[str] = Field( - default=None, - description="""Optional. The Cloud Storage URI of the dependency files in tar.gz format.""", - ) - pickle_object_gcs_uri: Optional[str] = Field( - default=None, - description="""Optional. The Cloud Storage URI of the pickled python object.""", - ) - python_version: Optional[str] = Field( - default=None, - description="""Optional. The Python version. Supported values are 3.9, 3.10, 3.11, 3.12, 3.13, 3.14. If not specified, the default value is 3.10.""", + custom_memory_topic_label: Optional[str] = Field( + default=None, description="""Optional. The custom memory topic label.""" ) - requirements_gcs_uri: Optional[str] = Field( - default=None, - description="""Optional. The Cloud Storage URI of the `requirements.txt` file""", + managed_memory_topic: Optional[ManagedTopicEnum] = Field( + default=None, description="""Optional. The managed memory topic.""" ) -class ReasoningEngineSpecPackageSpecDict(TypedDict, total=False): - """User-provided package specification, containing pickled object and package requirements.""" - - dependency_files_gcs_uri: Optional[str] - """Optional. The Cloud Storage URI of the dependency files in tar.gz format.""" - - pickle_object_gcs_uri: Optional[str] - """Optional. The Cloud Storage URI of the pickled python object.""" +class MemoryTopicIdDict(TypedDict, total=False): + """The topic ID for a memory.""" - python_version: Optional[str] - """Optional. The Python version. Supported values are 3.9, 3.10, 3.11, 3.12, 3.13, 3.14. If not specified, the default value is 3.10.""" + custom_memory_topic_label: Optional[str] + """Optional. The custom memory topic label.""" - requirements_gcs_uri: Optional[str] - """Optional. The Cloud Storage URI of the `requirements.txt` file""" + managed_memory_topic: Optional[ManagedTopicEnum] + """Optional. The managed memory topic.""" -ReasoningEngineSpecPackageSpecOrDict = Union[ - ReasoningEngineSpecPackageSpec, ReasoningEngineSpecPackageSpecDict -] +MemoryTopicIdOrDict = Union[MemoryTopicId, MemoryTopicIdDict] -class ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfig(_common.BaseModel): - """Configuration for the Agent Development Kit (ADK).""" +class MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemory( + _common.BaseModel +): + """A memory generated by the operation.""" - json_config: Optional[dict[str, Any]] = Field( + fact: Optional[str] = Field( + default=None, description="""Required. The fact to generate a memory from.""" + ) + topics: Optional[list[MemoryTopicId]] = Field( default=None, - description="""Required. The value of the ADK config in JSON format.""", + description="""Optional. The list of topics that the memory should be associated with. For example, use `custom_memory_topic_label = "jargon"` if the extracted memory is an example of memory extraction for the custom topic `jargon`.""", ) -class ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfigDict( +class MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemoryDict( TypedDict, total=False ): - """Configuration for the Agent Development Kit (ADK).""" + """A memory generated by the operation.""" - json_config: Optional[dict[str, Any]] - """Required. The value of the ADK config in JSON format.""" + fact: Optional[str] + """Required. The fact to generate a memory from.""" + topics: Optional[list[MemoryTopicIdDict]] + """Optional. The list of topics that the memory should be associated with. For example, use `custom_memory_topic_label = "jargon"` if the extracted memory is an example of memory extraction for the custom topic `jargon`.""" -ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfigOrDict = Union[ - ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfig, - ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfigDict, + +MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemoryOrDict = Union[ + MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemory, + MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemoryDict, ] -class ReasoningEngineSpecSourceCodeSpecInlineSource(_common.BaseModel): - """Specifies source code provided as a byte stream.""" +class MemoryBankCustomizationConfigGenerateMemoriesExample(_common.BaseModel): + """An example of how to generate memories for a particular scope.""" - source_archive: Optional[bytes] = Field( + conversation_source: Optional[ + MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSource + ] = Field(default=None, description="""A conversation source for the example.""") + generated_memories: Optional[ + list[MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemory] + ] = Field( default=None, - description="""Required. Input only. The application source code archive. It must be a compressed tarball (.tar.gz) file.""", + description="""Optional. The memories that are expected to be generated from the input conversation. An empty list indicates that no memories are expected to be generated for the input conversation.""", ) -class ReasoningEngineSpecSourceCodeSpecInlineSourceDict(TypedDict, total=False): - """Specifies source code provided as a byte stream.""" - - source_archive: Optional[bytes] - """Required. Input only. The application source code archive. It must be a compressed tarball (.tar.gz) file.""" - - -ReasoningEngineSpecSourceCodeSpecInlineSourceOrDict = Union[ - ReasoningEngineSpecSourceCodeSpecInlineSource, - ReasoningEngineSpecSourceCodeSpecInlineSourceDict, -] - - -class ReasoningEngineSpecSourceCodeSpecAgentConfigSource(_common.BaseModel): - """Specification for the deploying from agent config.""" - - adk_config: Optional[ - ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfig - ] = Field(default=None, description="""Required. The ADK configuration.""") - inline_source: Optional[ReasoningEngineSpecSourceCodeSpecInlineSource] = Field( - default=None, - description="""Optional. Any additional files needed to interpret the config. If a `requirements.txt` file is present in the `inline_source`, the corresponding packages will be installed. If no `requirements.txt` file is present in `inline_source`, then the latest version of `google-adk` will be installed for interpreting the ADK config.""", - ) - - -class ReasoningEngineSpecSourceCodeSpecAgentConfigSourceDict(TypedDict, total=False): - """Specification for the deploying from agent config.""" +class MemoryBankCustomizationConfigGenerateMemoriesExampleDict(TypedDict, total=False): + """An example of how to generate memories for a particular scope.""" - adk_config: Optional[ - ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfigDict + conversation_source: Optional[ + MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceDict ] - """Required. The ADK configuration.""" + """A conversation source for the example.""" - inline_source: Optional[ReasoningEngineSpecSourceCodeSpecInlineSourceDict] - """Optional. Any additional files needed to interpret the config. If a `requirements.txt` file is present in the `inline_source`, the corresponding packages will be installed. If no `requirements.txt` file is present in `inline_source`, then the latest version of `google-adk` will be installed for interpreting the ADK config.""" + generated_memories: Optional[ + list[MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemoryDict] + ] + """Optional. The memories that are expected to be generated from the input conversation. An empty list indicates that no memories are expected to be generated for the input conversation.""" -ReasoningEngineSpecSourceCodeSpecAgentConfigSourceOrDict = Union[ - ReasoningEngineSpecSourceCodeSpecAgentConfigSource, - ReasoningEngineSpecSourceCodeSpecAgentConfigSourceDict, +MemoryBankCustomizationConfigGenerateMemoriesExampleOrDict = Union[ + MemoryBankCustomizationConfigGenerateMemoriesExample, + MemoryBankCustomizationConfigGenerateMemoriesExampleDict, ] -class ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfig(_common.BaseModel): - """Specifies the configuration for fetching source code from a Git repository that is managed by Developer Connect. - - This includes the repository, revision, and directory to use. - """ +class MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopic(_common.BaseModel): + """A custom memory topic defined by the developer.""" - git_repository_link: Optional[str] = Field( - default=None, - description="""Required. The Developer Connect Git repository link, formatted as `projects/{project_id}/locations/{location_id}/connections/{connection_id}/gitRepositoryLink/{repository_link_id}`.""", - ) - dir: Optional[str] = Field( - default=None, - description="""Required. Directory, relative to the source root, in which to run the build.""", + label: Optional[str] = Field( + default=None, description="""Required. The label of the topic.""" ) - revision: Optional[str] = Field( + description: Optional[str] = Field( default=None, - description="""Required. The revision to fetch from the Git repository such as a branch, a tag, a commit SHA, or any Git ref.""", + description="""Required. Description of the memory topic. This should explain what information should be extracted for this topic.""", ) -class ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfigDict( +class MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopicDict( TypedDict, total=False ): - """Specifies the configuration for fetching source code from a Git repository that is managed by Developer Connect. - - This includes the repository, revision, and directory to use. - """ - - git_repository_link: Optional[str] - """Required. The Developer Connect Git repository link, formatted as `projects/{project_id}/locations/{location_id}/connections/{connection_id}/gitRepositoryLink/{repository_link_id}`.""" + """A custom memory topic defined by the developer.""" - dir: Optional[str] - """Required. Directory, relative to the source root, in which to run the build.""" + label: Optional[str] + """Required. The label of the topic.""" - revision: Optional[str] - """Required. The revision to fetch from the Git repository such as a branch, a tag, a commit SHA, or any Git ref.""" + description: Optional[str] + """Required. Description of the memory topic. This should explain what information should be extracted for this topic.""" -ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfigOrDict = Union[ - ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfig, - ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfigDict, +MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopicOrDict = Union[ + MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopic, + MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopicDict, ] -class ReasoningEngineSpecSourceCodeSpecDeveloperConnectSource(_common.BaseModel): - """Specifies source code to be fetched from a Git repository managed through the Developer Connect service.""" +class MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopic(_common.BaseModel): + """A managed memory topic defined by the system.""" - config: Optional[ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfig] = Field( - default=None, - description="""Required. The Developer Connect configuration that defines the specific repository, revision, and directory to use as the source code root.""", + managed_topic_enum: Optional[ManagedTopicEnum] = Field( + default=None, description="""Required. The managed topic.""" ) -class ReasoningEngineSpecSourceCodeSpecDeveloperConnectSourceDict( +class MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopicDict( TypedDict, total=False ): - """Specifies source code to be fetched from a Git repository managed through the Developer Connect service.""" + """A managed memory topic defined by the system.""" - config: Optional[ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfigDict] - """Required. The Developer Connect configuration that defines the specific repository, revision, and directory to use as the source code root.""" + managed_topic_enum: Optional[ManagedTopicEnum] + """Required. The managed topic.""" -ReasoningEngineSpecSourceCodeSpecDeveloperConnectSourceOrDict = Union[ - ReasoningEngineSpecSourceCodeSpecDeveloperConnectSource, - ReasoningEngineSpecSourceCodeSpecDeveloperConnectSourceDict, +MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopicOrDict = Union[ + MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopic, + MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopicDict, ] -class ReasoningEngineSpecSourceCodeSpecImageSpec(_common.BaseModel): - """The image spec for building an image (within a single build step). - - It is based on the config file (i.e. Dockerfile) in the source directory. - """ +class MemoryBankCustomizationConfigMemoryTopic(_common.BaseModel): + """A topic of information that should be extracted from conversations and stored as memories.""" - build_args: Optional[dict[str, str]] = Field( - default=None, - description="""Optional. Build arguments to be used. They will be passed through --build-arg flags.""", + custom_memory_topic: Optional[ + MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopic + ] = Field( + default=None, description="""A custom memory topic defined by the developer.""" + ) + managed_memory_topic: Optional[ + MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopic + ] = Field( + default=None, description="""A managed memory topic defined by Memory Bank.""" ) -class ReasoningEngineSpecSourceCodeSpecImageSpecDict(TypedDict, total=False): - """The image spec for building an image (within a single build step). +class MemoryBankCustomizationConfigMemoryTopicDict(TypedDict, total=False): + """A topic of information that should be extracted from conversations and stored as memories.""" - It is based on the config file (i.e. Dockerfile) in the source directory. - """ + custom_memory_topic: Optional[ + MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopicDict + ] + """A custom memory topic defined by the developer.""" - build_args: Optional[dict[str, str]] - """Optional. Build arguments to be used. They will be passed through --build-arg flags.""" + managed_memory_topic: Optional[ + MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopicDict + ] + """A managed memory topic defined by Memory Bank.""" -ReasoningEngineSpecSourceCodeSpecImageSpecOrDict = Union[ - ReasoningEngineSpecSourceCodeSpecImageSpec, - ReasoningEngineSpecSourceCodeSpecImageSpecDict, +MemoryBankCustomizationConfigMemoryTopicOrDict = Union[ + MemoryBankCustomizationConfigMemoryTopic, + MemoryBankCustomizationConfigMemoryTopicDict, ] -class ReasoningEngineSpecSourceCodeSpecPythonSpec(_common.BaseModel): - """Specification for running a Python application from source.""" +class MemoryBankCustomizationConfig(_common.BaseModel): + """Configuration for organizing memories for a particular scope.""" - entrypoint_module: Optional[str] = Field( + enable_third_person_memories: Optional[bool] = Field( default=None, - description="""Optional. The Python module to load as the entrypoint, specified as a fully qualified module name. For example: path.to.agent. If not specified, defaults to "agent". The project root will be added to Python sys.path, allowing imports to be specified relative to the root. This field should not be set if the source is `agent_config_source`.""", + description="""Optional. If true, then the memories will be generated in the third person (i.e. "The user generates memories with Memory Bank."). By default, the memories will be generated in the first person (i.e. "I generate memories with Memory Bank.")""", ) - entrypoint_object: Optional[str] = Field( + generate_memories_examples: Optional[ + list[MemoryBankCustomizationConfigGenerateMemoriesExample] + ] = Field( default=None, - description="""Optional. The name of the callable object within the `entrypoint_module` to use as the application If not specified, defaults to "root_agent". This field should not be set if the source is `agent_config_source`.""", + description="""Optional. Examples of how to generate memories for a particular scope.""", ) - requirements_file: Optional[str] = Field( + memory_topics: Optional[list[MemoryBankCustomizationConfigMemoryTopic]] = Field( default=None, - description="""Optional. The path to the requirements file, relative to the source root. If not specified, defaults to "requirements.txt".""", + description="""Optional. Topics of information that should be extracted from conversations and stored as memories. If not set, then Memory Bank's default topics will be used.""", ) - version: Optional[str] = Field( + scope_keys: Optional[list[str]] = Field( default=None, - description="""Optional. The version of Python to use. Support version includes 3.9, 3.10, 3.11, 3.12, 3.13, 3.14. If not specified, default value is 3.10.""", + description="""Optional. The scope keys (i.e. 'user_id') for which to use this config. A request's scope must include all of the provided keys for the config to be used (order does not matter). If empty, then the config will be used for all requests that do not have a more specific config. Only one default config is allowed per Memory Bank.""", ) -class ReasoningEngineSpecSourceCodeSpecPythonSpecDict(TypedDict, total=False): - """Specification for running a Python application from source.""" +class MemoryBankCustomizationConfigDict(TypedDict, total=False): + """Configuration for organizing memories for a particular scope.""" - entrypoint_module: Optional[str] - """Optional. The Python module to load as the entrypoint, specified as a fully qualified module name. For example: path.to.agent. If not specified, defaults to "agent". The project root will be added to Python sys.path, allowing imports to be specified relative to the root. This field should not be set if the source is `agent_config_source`.""" + enable_third_person_memories: Optional[bool] + """Optional. If true, then the memories will be generated in the third person (i.e. "The user generates memories with Memory Bank."). By default, the memories will be generated in the first person (i.e. "I generate memories with Memory Bank.")""" - entrypoint_object: Optional[str] - """Optional. The name of the callable object within the `entrypoint_module` to use as the application If not specified, defaults to "root_agent". This field should not be set if the source is `agent_config_source`.""" + generate_memories_examples: Optional[ + list[MemoryBankCustomizationConfigGenerateMemoriesExampleDict] + ] + """Optional. Examples of how to generate memories for a particular scope.""" - requirements_file: Optional[str] - """Optional. The path to the requirements file, relative to the source root. If not specified, defaults to "requirements.txt".""" + memory_topics: Optional[list[MemoryBankCustomizationConfigMemoryTopicDict]] + """Optional. Topics of information that should be extracted from conversations and stored as memories. If not set, then Memory Bank's default topics will be used.""" - version: Optional[str] - """Optional. The version of Python to use. Support version includes 3.9, 3.10, 3.11, 3.12, 3.13, 3.14. If not specified, default value is 3.10.""" + scope_keys: Optional[list[str]] + """Optional. The scope keys (i.e. 'user_id') for which to use this config. A request's scope must include all of the provided keys for the config to be used (order does not matter). If empty, then the config will be used for all requests that do not have a more specific config. Only one default config is allowed per Memory Bank.""" -ReasoningEngineSpecSourceCodeSpecPythonSpecOrDict = Union[ - ReasoningEngineSpecSourceCodeSpecPythonSpec, - ReasoningEngineSpecSourceCodeSpecPythonSpecDict, +MemoryBankCustomizationConfigOrDict = Union[ + MemoryBankCustomizationConfig, MemoryBankCustomizationConfigDict ] -class ReasoningEngineSpecSourceCodeSpec(_common.BaseModel): - """Specification for deploying from source code.""" +class ReasoningEngineContextSpecMemoryBankConfigGenerationConfig(_common.BaseModel): + """Configuration for how to generate memories.""" - agent_config_source: Optional[ - ReasoningEngineSpecSourceCodeSpecAgentConfigSource - ] = Field( - default=None, description="""Source code is generated from the agent config.""" - ) - developer_connect_source: Optional[ - ReasoningEngineSpecSourceCodeSpecDeveloperConnectSource - ] = Field( - default=None, - description="""Source code is in a Git repository managed by Developer Connect.""", - ) - image_spec: Optional[ReasoningEngineSpecSourceCodeSpecImageSpec] = Field( + model: Optional[str] = Field( default=None, - description="""Optional. Configuration for building an image with custom config file.""", - ) - inline_source: Optional[ReasoningEngineSpecSourceCodeSpecInlineSource] = Field( - default=None, description="""Source code is provided directly in the request.""" - ) - python_spec: Optional[ReasoningEngineSpecSourceCodeSpecPythonSpec] = Field( - default=None, description="""Configuration for a Python application.""" + description="""Required. The model used to generate memories. Format: `projects/{project}/locations/{location}/publishers/google/models/{model}`.""", ) -class ReasoningEngineSpecSourceCodeSpecDict(TypedDict, total=False): - """Specification for deploying from source code.""" - - agent_config_source: Optional[ - ReasoningEngineSpecSourceCodeSpecAgentConfigSourceDict - ] - """Source code is generated from the agent config.""" - - developer_connect_source: Optional[ - ReasoningEngineSpecSourceCodeSpecDeveloperConnectSourceDict - ] - """Source code is in a Git repository managed by Developer Connect.""" +class ReasoningEngineContextSpecMemoryBankConfigGenerationConfigDict( + TypedDict, total=False +): + """Configuration for how to generate memories.""" - image_spec: Optional[ReasoningEngineSpecSourceCodeSpecImageSpecDict] - """Optional. Configuration for building an image with custom config file.""" + model: Optional[str] + """Required. The model used to generate memories. Format: `projects/{project}/locations/{location}/publishers/google/models/{model}`.""" - inline_source: Optional[ReasoningEngineSpecSourceCodeSpecInlineSourceDict] - """Source code is provided directly in the request.""" - python_spec: Optional[ReasoningEngineSpecSourceCodeSpecPythonSpecDict] - """Configuration for a Python application.""" +ReasoningEngineContextSpecMemoryBankConfigGenerationConfigOrDict = Union[ + ReasoningEngineContextSpecMemoryBankConfigGenerationConfig, + ReasoningEngineContextSpecMemoryBankConfigGenerationConfigDict, +] -ReasoningEngineSpecSourceCodeSpecOrDict = Union[ - ReasoningEngineSpecSourceCodeSpec, ReasoningEngineSpecSourceCodeSpecDict +class ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfig( + _common.BaseModel +): + """Configuration for how to perform similarity search on memories.""" + + embedding_model: Optional[str] = Field( + default=None, + description="""Required. The model used to generate embeddings to lookup similar memories. Format: `projects/{project}/locations/{location}/publishers/google/models/{model}`.""", + ) + + +class ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfigDict( + TypedDict, total=False +): + """Configuration for how to perform similarity search on memories.""" + + embedding_model: Optional[str] + """Required. The model used to generate embeddings to lookup similar memories. Format: `projects/{project}/locations/{location}/publishers/google/models/{model}`.""" + + +ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfigOrDict = Union[ + ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfig, + ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfigDict, ] -class ReasoningEngineSpec(_common.BaseModel): - """The specification of an agent engine.""" +class ReasoningEngineContextSpecMemoryBankConfigTtlConfigGranularTtlConfig( + _common.BaseModel +): + """Configuration for TTL of the memories in the Memory Bank based on the action that created or updated the memory.""" - agent_card: Optional[dict[str, Any]] = Field( + create_ttl: Optional[str] = Field( default=None, - description="""Optional. The A2A Agent Card for the agent (if available). It follows the specification at https://a2a-protocol.org/latest/specification/#5-agent-discovery-the-agent-card.""", + description="""Optional. The TTL duration for memories uploaded via CreateMemory.""", ) - agent_framework: Optional[str] = Field( + generate_created_ttl: Optional[str] = Field( default=None, - description="""Optional. The OSS agent framework used to develop the agent. Currently supported values: "google-adk", "langchain", "langgraph", "ag2", "llama-index", "custom".""", + description="""Optional. The TTL duration for memories newly generated via GenerateMemories (GenerateMemoriesResponse.GeneratedMemory.Action.CREATED).""", ) - class_methods: Optional[list[dict[str, Any]]] = Field( + generate_updated_ttl: Optional[str] = Field( default=None, - description="""Optional. Declarations for object class methods in OpenAPI specification format.""", + description="""Optional. The TTL duration for memories updated via GenerateMemories (GenerateMemoriesResponse.GeneratedMemory.Action.UPDATED). In the case of an UPDATE action, the `expire_time` of the existing memory will be updated to the new value (now + TTL).""", ) - deployment_spec: Optional[ReasoningEngineSpecDeploymentSpec] = Field( + + +class ReasoningEngineContextSpecMemoryBankConfigTtlConfigGranularTtlConfigDict( + TypedDict, total=False +): + """Configuration for TTL of the memories in the Memory Bank based on the action that created or updated the memory.""" + + create_ttl: Optional[str] + """Optional. The TTL duration for memories uploaded via CreateMemory.""" + + generate_created_ttl: Optional[str] + """Optional. The TTL duration for memories newly generated via GenerateMemories (GenerateMemoriesResponse.GeneratedMemory.Action.CREATED).""" + + generate_updated_ttl: Optional[str] + """Optional. The TTL duration for memories updated via GenerateMemories (GenerateMemoriesResponse.GeneratedMemory.Action.UPDATED). In the case of an UPDATE action, the `expire_time` of the existing memory will be updated to the new value (now + TTL).""" + + +ReasoningEngineContextSpecMemoryBankConfigTtlConfigGranularTtlConfigOrDict = Union[ + ReasoningEngineContextSpecMemoryBankConfigTtlConfigGranularTtlConfig, + ReasoningEngineContextSpecMemoryBankConfigTtlConfigGranularTtlConfigDict, +] + + +class ReasoningEngineContextSpecMemoryBankConfigTtlConfig(_common.BaseModel): + """Configuration for automatically setting the TTL ("time-to-live") of the memories in the Memory Bank.""" + + default_ttl: Optional[str] = Field( default=None, - description="""Optional. The specification of a Reasoning Engine deployment.""", + description="""Optional. The default TTL duration of the memories in the Memory Bank. This applies to all operations that create or update a memory.""", ) - effective_identity: Optional[str] = Field( + granular_ttl_config: Optional[ + ReasoningEngineContextSpecMemoryBankConfigTtlConfigGranularTtlConfig + ] = Field( default=None, - description="""Output only. The identity to use for the Reasoning Engine. It can contain one of the following values: * service-{project}@gcp-sa-aiplatform-re.googleapis.com (for SERVICE_AGENT identity type) * {name}@{project}.gserviceaccount.com (for SERVICE_ACCOUNT identity type) * agents.global.{org}.system.id.goog/resources/aiplatform/projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine} (for AGENT_IDENTITY identity type)""", + description="""Optional. The granular TTL configuration of the memories in the Memory Bank.""", ) - identity_type: Optional[IdentityType] = Field( + memory_revision_default_ttl: Optional[str] = Field( default=None, - description="""Optional. The identity type to use for the Reasoning Engine. If not specified, the `service_account` field will be used if set, otherwise the default Vertex AI Reasoning Engine Service Agent in the project will be used.""", + description="""Optional. The default TTL duration of the memory revisions in the Memory Bank. This applies to all operations that create a memory revision. If not set, a default TTL of 365 days will be used.""", ) - package_spec: Optional[ReasoningEngineSpecPackageSpec] = Field( + + +class ReasoningEngineContextSpecMemoryBankConfigTtlConfigDict(TypedDict, total=False): + """Configuration for automatically setting the TTL ("time-to-live") of the memories in the Memory Bank.""" + + default_ttl: Optional[str] + """Optional. The default TTL duration of the memories in the Memory Bank. This applies to all operations that create or update a memory.""" + + granular_ttl_config: Optional[ + ReasoningEngineContextSpecMemoryBankConfigTtlConfigGranularTtlConfigDict + ] + """Optional. The granular TTL configuration of the memories in the Memory Bank.""" + + memory_revision_default_ttl: Optional[str] + """Optional. The default TTL duration of the memory revisions in the Memory Bank. This applies to all operations that create a memory revision. If not set, a default TTL of 365 days will be used.""" + + +ReasoningEngineContextSpecMemoryBankConfigTtlConfigOrDict = Union[ + ReasoningEngineContextSpecMemoryBankConfigTtlConfig, + ReasoningEngineContextSpecMemoryBankConfigTtlConfigDict, +] + + +class ReasoningEngineContextSpecMemoryBankConfig(_common.BaseModel): + """Specification for a Memory Bank.""" + + customization_configs: Optional[list[MemoryBankCustomizationConfig]] = Field( default=None, - description="""Optional. User provided package spec of the ReasoningEngine. Ignored when users directly specify a deployment image through `deployment_spec.first_party_image_override`, but keeping the field_behavior to avoid introducing breaking changes. The `deployment_source` field should not be set if `package_spec` is specified.""", + description="""Optional. Configuration for how to customize Memory Bank behavior for a particular scope.""", ) - service_account: Optional[str] = Field( + disable_memory_revisions: Optional[bool] = Field( default=None, - description="""Optional. The service account that the Reasoning Engine artifact runs as. It should have "roles/storage.objectViewer" for reading the user project's Cloud Storage and "roles/aiplatform.user" for using Vertex extensions. If not specified, the Vertex AI Reasoning Engine Service Agent in the project will be used.""", + description="""If true, no memory revisions will be created for any requests to the Memory Bank.""", ) - source_code_spec: Optional[ReasoningEngineSpecSourceCodeSpec] = Field( + generation_config: Optional[ + ReasoningEngineContextSpecMemoryBankConfigGenerationConfig + ] = Field( default=None, - description="""Deploy from source code files with a defined entrypoint.""", + description="""Optional. Configuration for how to generate memories for the Memory Bank.""", + ) + similarity_search_config: Optional[ + ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfig + ] = Field( + default=None, + description="""Optional. Configuration for how to perform similarity search on memories. If not set, the Memory Bank will use the default embedding model `text-embedding-005`.""", + ) + ttl_config: Optional[ReasoningEngineContextSpecMemoryBankConfigTtlConfig] = Field( + default=None, + description="""Optional. Configuration for automatic TTL ("time-to-live") of the memories in the Memory Bank. If not set, TTL will not be applied automatically. The TTL can be explicitly set by modifying the `expire_time` of each Memory resource.""", ) -class ReasoningEngineSpecDict(TypedDict, total=False): - """The specification of an agent engine.""" +class ReasoningEngineContextSpecMemoryBankConfigDict(TypedDict, total=False): + """Specification for a Memory Bank.""" - agent_card: Optional[dict[str, Any]] - """Optional. The A2A Agent Card for the agent (if available). It follows the specification at https://a2a-protocol.org/latest/specification/#5-agent-discovery-the-agent-card.""" + customization_configs: Optional[list[MemoryBankCustomizationConfigDict]] + """Optional. Configuration for how to customize Memory Bank behavior for a particular scope.""" - agent_framework: Optional[str] - """Optional. The OSS agent framework used to develop the agent. Currently supported values: "google-adk", "langchain", "langgraph", "ag2", "llama-index", "custom".""" + disable_memory_revisions: Optional[bool] + """If true, no memory revisions will be created for any requests to the Memory Bank.""" - class_methods: Optional[list[dict[str, Any]]] - """Optional. Declarations for object class methods in OpenAPI specification format.""" + generation_config: Optional[ + ReasoningEngineContextSpecMemoryBankConfigGenerationConfigDict + ] + """Optional. Configuration for how to generate memories for the Memory Bank.""" - deployment_spec: Optional[ReasoningEngineSpecDeploymentSpecDict] - """Optional. The specification of a Reasoning Engine deployment.""" + similarity_search_config: Optional[ + ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfigDict + ] + """Optional. Configuration for how to perform similarity search on memories. If not set, the Memory Bank will use the default embedding model `text-embedding-005`.""" - effective_identity: Optional[str] - """Output only. The identity to use for the Reasoning Engine. It can contain one of the following values: * service-{project}@gcp-sa-aiplatform-re.googleapis.com (for SERVICE_AGENT identity type) * {name}@{project}.gserviceaccount.com (for SERVICE_ACCOUNT identity type) * agents.global.{org}.system.id.goog/resources/aiplatform/projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine} (for AGENT_IDENTITY identity type)""" + ttl_config: Optional[ReasoningEngineContextSpecMemoryBankConfigTtlConfigDict] + """Optional. Configuration for automatic TTL ("time-to-live") of the memories in the Memory Bank. If not set, TTL will not be applied automatically. The TTL can be explicitly set by modifying the `expire_time` of each Memory resource.""" - identity_type: Optional[IdentityType] - """Optional. The identity type to use for the Reasoning Engine. If not specified, the `service_account` field will be used if set, otherwise the default Vertex AI Reasoning Engine Service Agent in the project will be used.""" - package_spec: Optional[ReasoningEngineSpecPackageSpecDict] - """Optional. User provided package spec of the ReasoningEngine. Ignored when users directly specify a deployment image through `deployment_spec.first_party_image_override`, but keeping the field_behavior to avoid introducing breaking changes. The `deployment_source` field should not be set if `package_spec` is specified.""" +ReasoningEngineContextSpecMemoryBankConfigOrDict = Union[ + ReasoningEngineContextSpecMemoryBankConfig, + ReasoningEngineContextSpecMemoryBankConfigDict, +] - service_account: Optional[str] - """Optional. The service account that the Reasoning Engine artifact runs as. It should have "roles/storage.objectViewer" for reading the user project's Cloud Storage and "roles/aiplatform.user" for using Vertex extensions. If not specified, the Vertex AI Reasoning Engine Service Agent in the project will be used.""" - source_code_spec: Optional[ReasoningEngineSpecSourceCodeSpecDict] - """Deploy from source code files with a defined entrypoint.""" +class ReasoningEngineContextSpec(_common.BaseModel): + """The configuration for agent engine sub-resources to manage context.""" + memory_bank_config: Optional[ReasoningEngineContextSpecMemoryBankConfig] = Field( + default=None, + description="""Optional. Specification for a Memory Bank, which manages memories for the Agent Engine.""", + ) -ReasoningEngineSpecOrDict = Union[ReasoningEngineSpec, ReasoningEngineSpecDict] +class ReasoningEngineContextSpecDict(TypedDict, total=False): + """The configuration for agent engine sub-resources to manage context.""" -class MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEvent( - _common.BaseModel -): - """The conversation source event for generating memories.""" + memory_bank_config: Optional[ReasoningEngineContextSpecMemoryBankConfigDict] + """Optional. Specification for a Memory Bank, which manages memories for the Agent Engine.""" - content: Optional[genai_types.Content] = Field( - default=None, description="""Required. The content of the event.""" + +ReasoningEngineContextSpecOrDict = Union[ + ReasoningEngineContextSpec, ReasoningEngineContextSpecDict +] + + +class SecretRef(_common.BaseModel): + """Reference to a secret stored in the Cloud Secret Manager that will provide the value for this environment variable.""" + + secret: Optional[str] = Field( + default=None, + description="""Required. The name of the secret in Cloud Secret Manager. Format: {secret_name}.""", + ) + version: Optional[str] = Field( + default=None, + description="""The Cloud Secret Manager secret version. Can be 'latest' for the latest version, an integer for a specific version, or a version alias.""", + ) + + +class SecretRefDict(TypedDict, total=False): + """Reference to a secret stored in the Cloud Secret Manager that will provide the value for this environment variable.""" + + secret: Optional[str] + """Required. The name of the secret in Cloud Secret Manager. Format: {secret_name}.""" + + version: Optional[str] + """The Cloud Secret Manager secret version. Can be 'latest' for the latest version, an integer for a specific version, or a version alias.""" + + +SecretRefOrDict = Union[SecretRef, SecretRefDict] + + +class SecretEnvVar(_common.BaseModel): + """Represents an environment variable where the value is a secret in Cloud Secret Manager.""" + + name: Optional[str] = Field( + default=None, + description="""Required. Name of the secret environment variable.""", + ) + secret_ref: Optional[SecretRef] = Field( + default=None, + description="""Required. Reference to a secret stored in the Cloud Secret Manager that will provide the value for this environment variable.""", + ) + + +class SecretEnvVarDict(TypedDict, total=False): + """Represents an environment variable where the value is a secret in Cloud Secret Manager.""" + + name: Optional[str] + """Required. Name of the secret environment variable.""" + + secret_ref: Optional[SecretRefDict] + """Required. Reference to a secret stored in the Cloud Secret Manager that will provide the value for this environment variable.""" + + +SecretEnvVarOrDict = Union[SecretEnvVar, SecretEnvVarDict] + + +class ReasoningEngineSpecDeploymentSpec(_common.BaseModel): + """The specification of a Reasoning Engine deployment.""" + + agent_server_mode: Optional[AgentServerMode] = Field( + default=None, description="""The agent server mode.""" + ) + container_concurrency: Optional[int] = Field( + default=None, + description="""Optional. Concurrency for each container and agent server. Recommended value: 2 * cpu + 1. Defaults to 9.""", + ) + env: Optional[list[EnvVar]] = Field( + default=None, + description="""Optional. Environment variables to be set with the Reasoning Engine deployment. The environment variables can be updated through the UpdateReasoningEngine API.""", + ) + max_instances: Optional[int] = Field( + default=None, + description="""Optional. The maximum number of application instances that can be launched to handle increased traffic. Defaults to 100. Range: [1, 1000]. If VPC-SC or PSC-I is enabled, the acceptable range is [1, 100].""", + ) + min_instances: Optional[int] = Field( + default=None, + description="""Optional. The minimum number of application instances that will be kept running at all times. Defaults to 1. Range: [0, 10].""", + ) + psc_interface_config: Optional[PscInterfaceConfig] = Field( + default=None, description="""Optional. Configuration for PSC-I.""" + ) + resource_limits: Optional[dict[str, str]] = Field( + default=None, + description="""Optional. Resource limits for each container. Only 'cpu' and 'memory' keys are supported. Defaults to {"cpu": "4", "memory": "4Gi"}. * The only supported values for CPU are '1', '2', '4', '6' and '8'. For more information, go to https://cloud.google.com/run/docs/configuring/cpu. * The only supported values for memory are '1Gi', '2Gi', ... '32 Gi'. * For required cpu on different memory values, go to https://cloud.google.com/run/docs/configuring/memory-limits""", + ) + secret_env: Optional[list[SecretEnvVar]] = Field( + default=None, + description="""Optional. Environment variables where the value is a secret in Cloud Secret Manager. To use this feature, add 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) to AI Platform Reasoning Engine Service Agent.""", + ) + + +class ReasoningEngineSpecDeploymentSpecDict(TypedDict, total=False): + """The specification of a Reasoning Engine deployment.""" + + agent_server_mode: Optional[AgentServerMode] + """The agent server mode.""" + + container_concurrency: Optional[int] + """Optional. Concurrency for each container and agent server. Recommended value: 2 * cpu + 1. Defaults to 9.""" + + env: Optional[list[EnvVarDict]] + """Optional. Environment variables to be set with the Reasoning Engine deployment. The environment variables can be updated through the UpdateReasoningEngine API.""" + + max_instances: Optional[int] + """Optional. The maximum number of application instances that can be launched to handle increased traffic. Defaults to 100. Range: [1, 1000]. If VPC-SC or PSC-I is enabled, the acceptable range is [1, 100].""" + + min_instances: Optional[int] + """Optional. The minimum number of application instances that will be kept running at all times. Defaults to 1. Range: [0, 10].""" + + psc_interface_config: Optional[PscInterfaceConfigDict] + """Optional. Configuration for PSC-I.""" + + resource_limits: Optional[dict[str, str]] + """Optional. Resource limits for each container. Only 'cpu' and 'memory' keys are supported. Defaults to {"cpu": "4", "memory": "4Gi"}. * The only supported values for CPU are '1', '2', '4', '6' and '8'. For more information, go to https://cloud.google.com/run/docs/configuring/cpu. * The only supported values for memory are '1Gi', '2Gi', ... '32 Gi'. * For required cpu on different memory values, go to https://cloud.google.com/run/docs/configuring/memory-limits""" + + secret_env: Optional[list[SecretEnvVarDict]] + """Optional. Environment variables where the value is a secret in Cloud Secret Manager. To use this feature, add 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) to AI Platform Reasoning Engine Service Agent.""" + + +ReasoningEngineSpecDeploymentSpecOrDict = Union[ + ReasoningEngineSpecDeploymentSpec, ReasoningEngineSpecDeploymentSpecDict +] + + +class ReasoningEngineSpecPackageSpec(_common.BaseModel): + """User-provided package specification, containing pickled object and package requirements.""" + + dependency_files_gcs_uri: Optional[str] = Field( + default=None, + description="""Optional. The Cloud Storage URI of the dependency files in tar.gz format.""", + ) + pickle_object_gcs_uri: Optional[str] = Field( + default=None, + description="""Optional. The Cloud Storage URI of the pickled python object.""", + ) + python_version: Optional[str] = Field( + default=None, + description="""Optional. The Python version. Supported values are 3.9, 3.10, 3.11, 3.12, 3.13, 3.14. If not specified, the default value is 3.10.""", + ) + requirements_gcs_uri: Optional[str] = Field( + default=None, + description="""Optional. The Cloud Storage URI of the `requirements.txt` file""", ) -class MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEventDict( - TypedDict, total=False -): - """The conversation source event for generating memories.""" +class ReasoningEngineSpecPackageSpecDict(TypedDict, total=False): + """User-provided package specification, containing pickled object and package requirements.""" - content: Optional[genai_types.ContentDict] - """Required. The content of the event.""" + dependency_files_gcs_uri: Optional[str] + """Optional. The Cloud Storage URI of the dependency files in tar.gz format.""" + pickle_object_gcs_uri: Optional[str] + """Optional. The Cloud Storage URI of the pickled python object.""" -MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEventOrDict = ( - Union[ - MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEvent, - MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEventDict, - ] -) + python_version: Optional[str] + """Optional. The Python version. Supported values are 3.9, 3.10, 3.11, 3.12, 3.13, 3.14. If not specified, the default value is 3.10.""" + requirements_gcs_uri: Optional[str] + """Optional. The Cloud Storage URI of the `requirements.txt` file""" -class MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSource( - _common.BaseModel -): - """A conversation source for the example. This is similar to `DirectContentsSource`.""" - events: Optional[ - list[ - MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEvent - ] - ] = Field( +ReasoningEngineSpecPackageSpecOrDict = Union[ + ReasoningEngineSpecPackageSpec, ReasoningEngineSpecPackageSpecDict +] + + +class ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfig(_common.BaseModel): + """Configuration for the Agent Development Kit (ADK).""" + + json_config: Optional[dict[str, Any]] = Field( default=None, - description="""Optional. The input conversation events for the example.""", + description="""Required. The value of the ADK config in JSON format.""", ) -class MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceDict( +class ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfigDict( TypedDict, total=False ): - """A conversation source for the example. This is similar to `DirectContentsSource`.""" + """Configuration for the Agent Development Kit (ADK).""" - events: Optional[ - list[ - MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEventDict - ] - ] - """Optional. The input conversation events for the example.""" + json_config: Optional[dict[str, Any]] + """Required. The value of the ADK config in JSON format.""" -MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceOrDict = Union[ - MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSource, - MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceDict, +ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfigOrDict = Union[ + ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfig, + ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfigDict, ] -class MemoryTopicId(_common.BaseModel): - """The topic ID for a memory.""" +class ReasoningEngineSpecSourceCodeSpecInlineSource(_common.BaseModel): + """Specifies source code provided as a byte stream.""" - custom_memory_topic_label: Optional[str] = Field( - default=None, description="""Optional. The custom memory topic label.""" - ) - managed_memory_topic: Optional[ManagedTopicEnum] = Field( - default=None, description="""Optional. The managed memory topic.""" + source_archive: Optional[bytes] = Field( + default=None, + description="""Required. Input only. The application source code archive. It must be a compressed tarball (.tar.gz) file.""", ) -class MemoryTopicIdDict(TypedDict, total=False): - """The topic ID for a memory.""" - - custom_memory_topic_label: Optional[str] - """Optional. The custom memory topic label.""" +class ReasoningEngineSpecSourceCodeSpecInlineSourceDict(TypedDict, total=False): + """Specifies source code provided as a byte stream.""" - managed_memory_topic: Optional[ManagedTopicEnum] - """Optional. The managed memory topic.""" + source_archive: Optional[bytes] + """Required. Input only. The application source code archive. It must be a compressed tarball (.tar.gz) file.""" -MemoryTopicIdOrDict = Union[MemoryTopicId, MemoryTopicIdDict] +ReasoningEngineSpecSourceCodeSpecInlineSourceOrDict = Union[ + ReasoningEngineSpecSourceCodeSpecInlineSource, + ReasoningEngineSpecSourceCodeSpecInlineSourceDict, +] -class MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemory( - _common.BaseModel -): - """A memory generated by the operation.""" +class ReasoningEngineSpecSourceCodeSpecAgentConfigSource(_common.BaseModel): + """Specification for the deploying from agent config.""" - fact: Optional[str] = Field( - default=None, description="""Required. The fact to generate a memory from.""" - ) - topics: Optional[list[MemoryTopicId]] = Field( + adk_config: Optional[ + ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfig + ] = Field(default=None, description="""Required. The ADK configuration.""") + inline_source: Optional[ReasoningEngineSpecSourceCodeSpecInlineSource] = Field( default=None, - description="""Optional. The list of topics that the memory should be associated with. For example, use `custom_memory_topic_label = "jargon"` if the extracted memory is an example of memory extraction for the custom topic `jargon`.""", + description="""Optional. Any additional files needed to interpret the config. If a `requirements.txt` file is present in the `inline_source`, the corresponding packages will be installed. If no `requirements.txt` file is present in `inline_source`, then the latest version of `google-adk` will be installed for interpreting the ADK config.""", ) -class MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemoryDict( - TypedDict, total=False -): - """A memory generated by the operation.""" +class ReasoningEngineSpecSourceCodeSpecAgentConfigSourceDict(TypedDict, total=False): + """Specification for the deploying from agent config.""" - fact: Optional[str] - """Required. The fact to generate a memory from.""" + adk_config: Optional[ + ReasoningEngineSpecSourceCodeSpecAgentConfigSourceAdkConfigDict + ] + """Required. The ADK configuration.""" - topics: Optional[list[MemoryTopicIdDict]] - """Optional. The list of topics that the memory should be associated with. For example, use `custom_memory_topic_label = "jargon"` if the extracted memory is an example of memory extraction for the custom topic `jargon`.""" + inline_source: Optional[ReasoningEngineSpecSourceCodeSpecInlineSourceDict] + """Optional. Any additional files needed to interpret the config. If a `requirements.txt` file is present in the `inline_source`, the corresponding packages will be installed. If no `requirements.txt` file is present in `inline_source`, then the latest version of `google-adk` will be installed for interpreting the ADK config.""" -MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemoryOrDict = Union[ - MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemory, - MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemoryDict, +ReasoningEngineSpecSourceCodeSpecAgentConfigSourceOrDict = Union[ + ReasoningEngineSpecSourceCodeSpecAgentConfigSource, + ReasoningEngineSpecSourceCodeSpecAgentConfigSourceDict, ] -class MemoryBankCustomizationConfigGenerateMemoriesExample(_common.BaseModel): - """An example of how to generate memories for a particular scope.""" +class ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfig(_common.BaseModel): + """Specifies the configuration for fetching source code from a Git repository that is managed by Developer Connect. - conversation_source: Optional[ - MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSource - ] = Field(default=None, description="""A conversation source for the example.""") - generated_memories: Optional[ - list[MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemory] - ] = Field( + This includes the repository, revision, and directory to use. + """ + + git_repository_link: Optional[str] = Field( default=None, - description="""Optional. The memories that are expected to be generated from the input conversation. An empty list indicates that no memories are expected to be generated for the input conversation.""", + description="""Required. The Developer Connect Git repository link, formatted as `projects/{project_id}/locations/{location_id}/connections/{connection_id}/gitRepositoryLink/{repository_link_id}`.""", + ) + dir: Optional[str] = Field( + default=None, + description="""Required. Directory, relative to the source root, in which to run the build.""", + ) + revision: Optional[str] = Field( + default=None, + description="""Required. The revision to fetch from the Git repository such as a branch, a tag, a commit SHA, or any Git ref.""", ) -class MemoryBankCustomizationConfigGenerateMemoriesExampleDict(TypedDict, total=False): - """An example of how to generate memories for a particular scope.""" +class ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfigDict( + TypedDict, total=False +): + """Specifies the configuration for fetching source code from a Git repository that is managed by Developer Connect. - conversation_source: Optional[ - MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceDict - ] - """A conversation source for the example.""" + This includes the repository, revision, and directory to use. + """ - generated_memories: Optional[ - list[MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemoryDict] - ] - """Optional. The memories that are expected to be generated from the input conversation. An empty list indicates that no memories are expected to be generated for the input conversation.""" + git_repository_link: Optional[str] + """Required. The Developer Connect Git repository link, formatted as `projects/{project_id}/locations/{location_id}/connections/{connection_id}/gitRepositoryLink/{repository_link_id}`.""" + dir: Optional[str] + """Required. Directory, relative to the source root, in which to run the build.""" -MemoryBankCustomizationConfigGenerateMemoriesExampleOrDict = Union[ - MemoryBankCustomizationConfigGenerateMemoriesExample, - MemoryBankCustomizationConfigGenerateMemoriesExampleDict, + revision: Optional[str] + """Required. The revision to fetch from the Git repository such as a branch, a tag, a commit SHA, or any Git ref.""" + + +ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfigOrDict = Union[ + ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfig, + ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfigDict, ] -class MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopic(_common.BaseModel): - """A custom memory topic defined by the developer.""" +class ReasoningEngineSpecSourceCodeSpecDeveloperConnectSource(_common.BaseModel): + """Specifies source code to be fetched from a Git repository managed through the Developer Connect service.""" - label: Optional[str] = Field( - default=None, description="""Required. The label of the topic.""" - ) - description: Optional[str] = Field( + config: Optional[ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfig] = Field( default=None, - description="""Required. Description of the memory topic. This should explain what information should be extracted for this topic.""", + description="""Required. The Developer Connect configuration that defines the specific repository, revision, and directory to use as the source code root.""", ) -class MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopicDict( +class ReasoningEngineSpecSourceCodeSpecDeveloperConnectSourceDict( TypedDict, total=False ): - """A custom memory topic defined by the developer.""" - - label: Optional[str] - """Required. The label of the topic.""" + """Specifies source code to be fetched from a Git repository managed through the Developer Connect service.""" - description: Optional[str] - """Required. Description of the memory topic. This should explain what information should be extracted for this topic.""" + config: Optional[ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfigDict] + """Required. The Developer Connect configuration that defines the specific repository, revision, and directory to use as the source code root.""" -MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopicOrDict = Union[ - MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopic, - MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopicDict, +ReasoningEngineSpecSourceCodeSpecDeveloperConnectSourceOrDict = Union[ + ReasoningEngineSpecSourceCodeSpecDeveloperConnectSource, + ReasoningEngineSpecSourceCodeSpecDeveloperConnectSourceDict, ] -class MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopic(_common.BaseModel): - """A managed memory topic defined by the system.""" +class ReasoningEngineSpecSourceCodeSpecImageSpec(_common.BaseModel): + """The image spec for building an image (within a single build step). - managed_topic_enum: Optional[ManagedTopicEnum] = Field( - default=None, description="""Required. The managed topic.""" + It is based on the config file (i.e. Dockerfile) in the source directory. + """ + + build_args: Optional[dict[str, str]] = Field( + default=None, + description="""Optional. Build arguments to be used. They will be passed through --build-arg flags.""", ) -class MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopicDict( - TypedDict, total=False -): - """A managed memory topic defined by the system.""" +class ReasoningEngineSpecSourceCodeSpecImageSpecDict(TypedDict, total=False): + """The image spec for building an image (within a single build step). - managed_topic_enum: Optional[ManagedTopicEnum] - """Required. The managed topic.""" + It is based on the config file (i.e. Dockerfile) in the source directory. + """ + build_args: Optional[dict[str, str]] + """Optional. Build arguments to be used. They will be passed through --build-arg flags.""" -MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopicOrDict = Union[ - MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopic, - MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopicDict, + +ReasoningEngineSpecSourceCodeSpecImageSpecOrDict = Union[ + ReasoningEngineSpecSourceCodeSpecImageSpec, + ReasoningEngineSpecSourceCodeSpecImageSpecDict, ] -class MemoryBankCustomizationConfigMemoryTopic(_common.BaseModel): - """A topic of information that should be extracted from conversations and stored as memories.""" +class ReasoningEngineSpecSourceCodeSpecPythonSpec(_common.BaseModel): + """Specification for running a Python application from source.""" - custom_memory_topic: Optional[ - MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopic - ] = Field( - default=None, description="""A custom memory topic defined by the developer.""" + entrypoint_module: Optional[str] = Field( + default=None, + description="""Optional. The Python module to load as the entrypoint, specified as a fully qualified module name. For example: path.to.agent. If not specified, defaults to "agent". The project root will be added to Python sys.path, allowing imports to be specified relative to the root. This field should not be set if the source is `agent_config_source`.""", + ) + entrypoint_object: Optional[str] = Field( + default=None, + description="""Optional. The name of the callable object within the `entrypoint_module` to use as the application If not specified, defaults to "root_agent". This field should not be set if the source is `agent_config_source`.""", ) - managed_memory_topic: Optional[ - MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopic - ] = Field( - default=None, description="""A managed memory topic defined by Memory Bank.""" + requirements_file: Optional[str] = Field( + default=None, + description="""Optional. The path to the requirements file, relative to the source root. If not specified, defaults to "requirements.txt".""", + ) + version: Optional[str] = Field( + default=None, + description="""Optional. The version of Python to use. Support version includes 3.9, 3.10, 3.11, 3.12, 3.13, 3.14. If not specified, default value is 3.10.""", ) -class MemoryBankCustomizationConfigMemoryTopicDict(TypedDict, total=False): - """A topic of information that should be extracted from conversations and stored as memories.""" +class ReasoningEngineSpecSourceCodeSpecPythonSpecDict(TypedDict, total=False): + """Specification for running a Python application from source.""" - custom_memory_topic: Optional[ - MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopicDict - ] - """A custom memory topic defined by the developer.""" + entrypoint_module: Optional[str] + """Optional. The Python module to load as the entrypoint, specified as a fully qualified module name. For example: path.to.agent. If not specified, defaults to "agent". The project root will be added to Python sys.path, allowing imports to be specified relative to the root. This field should not be set if the source is `agent_config_source`.""" - managed_memory_topic: Optional[ - MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopicDict - ] - """A managed memory topic defined by Memory Bank.""" + entrypoint_object: Optional[str] + """Optional. The name of the callable object within the `entrypoint_module` to use as the application If not specified, defaults to "root_agent". This field should not be set if the source is `agent_config_source`.""" + requirements_file: Optional[str] + """Optional. The path to the requirements file, relative to the source root. If not specified, defaults to "requirements.txt".""" -MemoryBankCustomizationConfigMemoryTopicOrDict = Union[ - MemoryBankCustomizationConfigMemoryTopic, - MemoryBankCustomizationConfigMemoryTopicDict, + version: Optional[str] + """Optional. The version of Python to use. Support version includes 3.9, 3.10, 3.11, 3.12, 3.13, 3.14. If not specified, default value is 3.10.""" + + +ReasoningEngineSpecSourceCodeSpecPythonSpecOrDict = Union[ + ReasoningEngineSpecSourceCodeSpecPythonSpec, + ReasoningEngineSpecSourceCodeSpecPythonSpecDict, ] -class MemoryBankCustomizationConfig(_common.BaseModel): - """Configuration for organizing memories for a particular scope.""" +class ReasoningEngineSpecSourceCodeSpec(_common.BaseModel): + """Specification for deploying from source code.""" - enable_third_person_memories: Optional[bool] = Field( - default=None, - description="""Optional. If true, then the memories will be generated in the third person (i.e. "The user generates memories with Memory Bank."). By default, the memories will be generated in the first person (i.e. "I generate memories with Memory Bank.")""", + agent_config_source: Optional[ + ReasoningEngineSpecSourceCodeSpecAgentConfigSource + ] = Field( + default=None, description="""Source code is generated from the agent config.""" ) - generate_memories_examples: Optional[ - list[MemoryBankCustomizationConfigGenerateMemoriesExample] + developer_connect_source: Optional[ + ReasoningEngineSpecSourceCodeSpecDeveloperConnectSource ] = Field( default=None, - description="""Optional. Examples of how to generate memories for a particular scope.""", + description="""Source code is in a Git repository managed by Developer Connect.""", ) - memory_topics: Optional[list[MemoryBankCustomizationConfigMemoryTopic]] = Field( + image_spec: Optional[ReasoningEngineSpecSourceCodeSpecImageSpec] = Field( default=None, - description="""Optional. Topics of information that should be extracted from conversations and stored as memories. If not set, then Memory Bank's default topics will be used.""", + description="""Optional. Configuration for building an image with custom config file.""", ) - scope_keys: Optional[list[str]] = Field( - default=None, - description="""Optional. The scope keys (i.e. 'user_id') for which to use this config. A request's scope must include all of the provided keys for the config to be used (order does not matter). If empty, then the config will be used for all requests that do not have a more specific config. Only one default config is allowed per Memory Bank.""", + inline_source: Optional[ReasoningEngineSpecSourceCodeSpecInlineSource] = Field( + default=None, description="""Source code is provided directly in the request.""" + ) + python_spec: Optional[ReasoningEngineSpecSourceCodeSpecPythonSpec] = Field( + default=None, description="""Configuration for a Python application.""" ) -class MemoryBankCustomizationConfigDict(TypedDict, total=False): - """Configuration for organizing memories for a particular scope.""" +class ReasoningEngineSpecSourceCodeSpecDict(TypedDict, total=False): + """Specification for deploying from source code.""" - enable_third_person_memories: Optional[bool] - """Optional. If true, then the memories will be generated in the third person (i.e. "The user generates memories with Memory Bank."). By default, the memories will be generated in the first person (i.e. "I generate memories with Memory Bank.")""" + agent_config_source: Optional[ + ReasoningEngineSpecSourceCodeSpecAgentConfigSourceDict + ] + """Source code is generated from the agent config.""" - generate_memories_examples: Optional[ - list[MemoryBankCustomizationConfigGenerateMemoriesExampleDict] + developer_connect_source: Optional[ + ReasoningEngineSpecSourceCodeSpecDeveloperConnectSourceDict ] - """Optional. Examples of how to generate memories for a particular scope.""" + """Source code is in a Git repository managed by Developer Connect.""" - memory_topics: Optional[list[MemoryBankCustomizationConfigMemoryTopicDict]] - """Optional. Topics of information that should be extracted from conversations and stored as memories. If not set, then Memory Bank's default topics will be used.""" + image_spec: Optional[ReasoningEngineSpecSourceCodeSpecImageSpecDict] + """Optional. Configuration for building an image with custom config file.""" - scope_keys: Optional[list[str]] - """Optional. The scope keys (i.e. 'user_id') for which to use this config. A request's scope must include all of the provided keys for the config to be used (order does not matter). If empty, then the config will be used for all requests that do not have a more specific config. Only one default config is allowed per Memory Bank.""" + inline_source: Optional[ReasoningEngineSpecSourceCodeSpecInlineSourceDict] + """Source code is provided directly in the request.""" + python_spec: Optional[ReasoningEngineSpecSourceCodeSpecPythonSpecDict] + """Configuration for a Python application.""" -MemoryBankCustomizationConfigOrDict = Union[ - MemoryBankCustomizationConfig, MemoryBankCustomizationConfigDict + +ReasoningEngineSpecSourceCodeSpecOrDict = Union[ + ReasoningEngineSpecSourceCodeSpec, ReasoningEngineSpecSourceCodeSpecDict ] -class ReasoningEngineContextSpecMemoryBankConfigGenerationConfig(_common.BaseModel): - """Configuration for how to generate memories.""" +class ReasoningEngineSpec(_common.BaseModel): + """The specification of an agent engine.""" - model: Optional[str] = Field( + agent_card: Optional[dict[str, Any]] = Field( default=None, - description="""Required. The model used to generate memories. Format: `projects/{project}/locations/{location}/publishers/google/models/{model}`.""", + description="""Optional. The A2A Agent Card for the agent (if available). It follows the specification at https://a2a-protocol.org/latest/specification/#5-agent-discovery-the-agent-card.""", + ) + agent_framework: Optional[str] = Field( + default=None, + description="""Optional. The OSS agent framework used to develop the agent. Currently supported values: "google-adk", "langchain", "langgraph", "ag2", "llama-index", "custom".""", + ) + class_methods: Optional[list[dict[str, Any]]] = Field( + default=None, + description="""Optional. Declarations for object class methods in OpenAPI specification format.""", + ) + deployment_spec: Optional[ReasoningEngineSpecDeploymentSpec] = Field( + default=None, + description="""Optional. The specification of a Reasoning Engine deployment.""", + ) + effective_identity: Optional[str] = Field( + default=None, + description="""Output only. The identity to use for the Reasoning Engine. It can contain one of the following values: * service-{project}@gcp-sa-aiplatform-re.googleapis.com (for SERVICE_AGENT identity type) * {name}@{project}.gserviceaccount.com (for SERVICE_ACCOUNT identity type) * agents.global.{org}.system.id.goog/resources/aiplatform/projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine} (for AGENT_IDENTITY identity type)""", + ) + identity_type: Optional[IdentityType] = Field( + default=None, + description="""Optional. The identity type to use for the Reasoning Engine. If not specified, the `service_account` field will be used if set, otherwise the default Vertex AI Reasoning Engine Service Agent in the project will be used.""", + ) + package_spec: Optional[ReasoningEngineSpecPackageSpec] = Field( + default=None, + description="""Optional. User provided package spec of the ReasoningEngine. Ignored when users directly specify a deployment image through `deployment_spec.first_party_image_override`, but keeping the field_behavior to avoid introducing breaking changes. The `deployment_source` field should not be set if `package_spec` is specified.""", + ) + service_account: Optional[str] = Field( + default=None, + description="""Optional. The service account that the Reasoning Engine artifact runs as. It should have "roles/storage.objectViewer" for reading the user project's Cloud Storage and "roles/aiplatform.user" for using Vertex extensions. If not specified, the Vertex AI Reasoning Engine Service Agent in the project will be used.""", + ) + source_code_spec: Optional[ReasoningEngineSpecSourceCodeSpec] = Field( + default=None, + description="""Deploy from source code files with a defined entrypoint.""", ) -class ReasoningEngineContextSpecMemoryBankConfigGenerationConfigDict( - TypedDict, total=False -): - """Configuration for how to generate memories.""" +class ReasoningEngineSpecDict(TypedDict, total=False): + """The specification of an agent engine.""" - model: Optional[str] - """Required. The model used to generate memories. Format: `projects/{project}/locations/{location}/publishers/google/models/{model}`.""" + agent_card: Optional[dict[str, Any]] + """Optional. The A2A Agent Card for the agent (if available). It follows the specification at https://a2a-protocol.org/latest/specification/#5-agent-discovery-the-agent-card.""" + agent_framework: Optional[str] + """Optional. The OSS agent framework used to develop the agent. Currently supported values: "google-adk", "langchain", "langgraph", "ag2", "llama-index", "custom".""" -ReasoningEngineContextSpecMemoryBankConfigGenerationConfigOrDict = Union[ - ReasoningEngineContextSpecMemoryBankConfigGenerationConfig, - ReasoningEngineContextSpecMemoryBankConfigGenerationConfigDict, -] + class_methods: Optional[list[dict[str, Any]]] + """Optional. Declarations for object class methods in OpenAPI specification format.""" + deployment_spec: Optional[ReasoningEngineSpecDeploymentSpecDict] + """Optional. The specification of a Reasoning Engine deployment.""" -class ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfig( - _common.BaseModel -): - """Configuration for how to perform similarity search on memories.""" + effective_identity: Optional[str] + """Output only. The identity to use for the Reasoning Engine. It can contain one of the following values: * service-{project}@gcp-sa-aiplatform-re.googleapis.com (for SERVICE_AGENT identity type) * {name}@{project}.gserviceaccount.com (for SERVICE_ACCOUNT identity type) * agents.global.{org}.system.id.goog/resources/aiplatform/projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine} (for AGENT_IDENTITY identity type)""" - embedding_model: Optional[str] = Field( - default=None, - description="""Required. The model used to generate embeddings to lookup similar memories. Format: `projects/{project}/locations/{location}/publishers/google/models/{model}`.""", - ) + identity_type: Optional[IdentityType] + """Optional. The identity type to use for the Reasoning Engine. If not specified, the `service_account` field will be used if set, otherwise the default Vertex AI Reasoning Engine Service Agent in the project will be used.""" + package_spec: Optional[ReasoningEngineSpecPackageSpecDict] + """Optional. User provided package spec of the ReasoningEngine. Ignored when users directly specify a deployment image through `deployment_spec.first_party_image_override`, but keeping the field_behavior to avoid introducing breaking changes. The `deployment_source` field should not be set if `package_spec` is specified.""" -class ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfigDict( - TypedDict, total=False -): - """Configuration for how to perform similarity search on memories.""" + service_account: Optional[str] + """Optional. The service account that the Reasoning Engine artifact runs as. It should have "roles/storage.objectViewer" for reading the user project's Cloud Storage and "roles/aiplatform.user" for using Vertex extensions. If not specified, the Vertex AI Reasoning Engine Service Agent in the project will be used.""" - embedding_model: Optional[str] - """Required. The model used to generate embeddings to lookup similar memories. Format: `projects/{project}/locations/{location}/publishers/google/models/{model}`.""" + source_code_spec: Optional[ReasoningEngineSpecSourceCodeSpecDict] + """Deploy from source code files with a defined entrypoint.""" -ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfigOrDict = Union[ - ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfig, - ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfigDict, -] +ReasoningEngineSpecOrDict = Union[ReasoningEngineSpec, ReasoningEngineSpecDict] -class ReasoningEngineContextSpecMemoryBankConfigTtlConfigGranularTtlConfig( - _common.BaseModel -): - """Configuration for TTL of the memories in the Memory Bank based on the action that created or updated the memory.""" +class ReasoningEngine(_common.BaseModel): + """An agent engine.""" - create_ttl: Optional[str] = Field( + encryption_spec: Optional[genai_types.EncryptionSpec] = Field( default=None, - description="""Optional. The TTL duration for memories uploaded via CreateMemory.""", + description="""Customer-managed encryption key spec for a ReasoningEngine. If set, this ReasoningEngine and all sub-resources of this ReasoningEngine will be secured by this key.""", ) - generate_created_ttl: Optional[str] = Field( + context_spec: Optional[ReasoningEngineContextSpec] = Field( default=None, - description="""Optional. The TTL duration for memories newly generated via GenerateMemories (GenerateMemoriesResponse.GeneratedMemory.Action.CREATED).""", + description="""Optional. Configuration for how Agent Engine sub-resources should manage context.""", ) - generate_updated_ttl: Optional[str] = Field( + create_time: Optional[datetime.datetime] = Field( default=None, - description="""Optional. The TTL duration for memories updated via GenerateMemories (GenerateMemoriesResponse.GeneratedMemory.Action.UPDATED). In the case of an UPDATE action, the `expire_time` of the existing memory will be updated to the new value (now + TTL).""", + description="""Output only. Timestamp when this ReasoningEngine was created.""", + ) + description: Optional[str] = Field( + default=None, + description="""Optional. The description of the ReasoningEngine.""", + ) + display_name: Optional[str] = Field( + default=None, + description="""Required. The display name of the ReasoningEngine.""", + ) + etag: Optional[str] = Field( + default=None, + description="""Optional. Used to perform consistent read-modify-write updates. If not set, a blind "overwrite" update happens.""", + ) + labels: Optional[dict[str, str]] = Field( + default=None, description="""Labels for the ReasoningEngine.""" + ) + name: Optional[str] = Field( + default=None, + description="""Identifier. The resource name of the ReasoningEngine. Format: `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}`""", + ) + spec: Optional[ReasoningEngineSpec] = Field( + default=None, description="""Optional. Configurations of the ReasoningEngine""" + ) + update_time: Optional[datetime.datetime] = Field( + default=None, + description="""Output only. Timestamp when this ReasoningEngine was most recently updated.""", ) -class ReasoningEngineContextSpecMemoryBankConfigTtlConfigGranularTtlConfigDict( - TypedDict, total=False -): - """Configuration for TTL of the memories in the Memory Bank based on the action that created or updated the memory.""" - - create_ttl: Optional[str] - """Optional. The TTL duration for memories uploaded via CreateMemory.""" - - generate_created_ttl: Optional[str] - """Optional. The TTL duration for memories newly generated via GenerateMemories (GenerateMemoriesResponse.GeneratedMemory.Action.CREATED).""" - - generate_updated_ttl: Optional[str] - """Optional. The TTL duration for memories updated via GenerateMemories (GenerateMemoriesResponse.GeneratedMemory.Action.UPDATED). In the case of an UPDATE action, the `expire_time` of the existing memory will be updated to the new value (now + TTL).""" +class ReasoningEngineDict(TypedDict, total=False): + """An agent engine.""" + encryption_spec: Optional[genai_types.EncryptionSpecDict] + """Customer-managed encryption key spec for a ReasoningEngine. If set, this ReasoningEngine and all sub-resources of this ReasoningEngine will be secured by this key.""" -ReasoningEngineContextSpecMemoryBankConfigTtlConfigGranularTtlConfigOrDict = Union[ - ReasoningEngineContextSpecMemoryBankConfigTtlConfigGranularTtlConfig, - ReasoningEngineContextSpecMemoryBankConfigTtlConfigGranularTtlConfigDict, -] + context_spec: Optional[ReasoningEngineContextSpecDict] + """Optional. Configuration for how Agent Engine sub-resources should manage context.""" + create_time: Optional[datetime.datetime] + """Output only. Timestamp when this ReasoningEngine was created.""" -class ReasoningEngineContextSpecMemoryBankConfigTtlConfig(_common.BaseModel): - """Configuration for automatically setting the TTL ("time-to-live") of the memories in the Memory Bank.""" + description: Optional[str] + """Optional. The description of the ReasoningEngine.""" - default_ttl: Optional[str] = Field( - default=None, - description="""Optional. The default TTL duration of the memories in the Memory Bank. This applies to all operations that create or update a memory.""", - ) - granular_ttl_config: Optional[ - ReasoningEngineContextSpecMemoryBankConfigTtlConfigGranularTtlConfig - ] = Field( - default=None, - description="""Optional. The granular TTL configuration of the memories in the Memory Bank.""", - ) - memory_revision_default_ttl: Optional[str] = Field( - default=None, - description="""Optional. The default TTL duration of the memory revisions in the Memory Bank. This applies to all operations that create a memory revision. If not set, a default TTL of 365 days will be used.""", - ) + display_name: Optional[str] + """Required. The display name of the ReasoningEngine.""" + etag: Optional[str] + """Optional. Used to perform consistent read-modify-write updates. If not set, a blind "overwrite" update happens.""" -class ReasoningEngineContextSpecMemoryBankConfigTtlConfigDict(TypedDict, total=False): - """Configuration for automatically setting the TTL ("time-to-live") of the memories in the Memory Bank.""" + labels: Optional[dict[str, str]] + """Labels for the ReasoningEngine.""" - default_ttl: Optional[str] - """Optional. The default TTL duration of the memories in the Memory Bank. This applies to all operations that create or update a memory.""" + name: Optional[str] + """Identifier. The resource name of the ReasoningEngine. Format: `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}`""" - granular_ttl_config: Optional[ - ReasoningEngineContextSpecMemoryBankConfigTtlConfigGranularTtlConfigDict - ] - """Optional. The granular TTL configuration of the memories in the Memory Bank.""" + spec: Optional[ReasoningEngineSpecDict] + """Optional. Configurations of the ReasoningEngine""" - memory_revision_default_ttl: Optional[str] - """Optional. The default TTL duration of the memory revisions in the Memory Bank. This applies to all operations that create a memory revision. If not set, a default TTL of 365 days will be used.""" + update_time: Optional[datetime.datetime] + """Output only. Timestamp when this ReasoningEngine was most recently updated.""" -ReasoningEngineContextSpecMemoryBankConfigTtlConfigOrDict = Union[ - ReasoningEngineContextSpecMemoryBankConfigTtlConfig, - ReasoningEngineContextSpecMemoryBankConfigTtlConfigDict, -] +ReasoningEngineOrDict = Union[ReasoningEngine, ReasoningEngineDict] -class ReasoningEngineContextSpecMemoryBankConfig(_common.BaseModel): - """Specification for a Memory Bank.""" +class AgentEngineOperation(_common.BaseModel): + """Operation that has an agent engine as a response.""" - customization_configs: Optional[list[MemoryBankCustomizationConfig]] = Field( + name: Optional[str] = Field( default=None, - description="""Optional. Configuration for how to customize Memory Bank behavior for a particular scope.""", + description="""The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.""", ) - disable_memory_revisions: Optional[bool] = Field( + metadata: Optional[dict[str, Any]] = Field( default=None, - description="""If true, no memory revisions will be created for any requests to the Memory Bank.""", + description="""Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.""", ) - generation_config: Optional[ - ReasoningEngineContextSpecMemoryBankConfigGenerationConfig - ] = Field( + done: Optional[bool] = Field( default=None, - description="""Optional. Configuration for how to generate memories for the Memory Bank.""", + description="""If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.""", ) - similarity_search_config: Optional[ - ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfig - ] = Field( + error: Optional[dict[str, Any]] = Field( default=None, - description="""Optional. Configuration for how to perform similarity search on memories. If not set, the Memory Bank will use the default embedding model `text-embedding-005`.""", + description="""The error result of the operation in case of failure or cancellation.""", ) - ttl_config: Optional[ReasoningEngineContextSpecMemoryBankConfigTtlConfig] = Field( - default=None, - description="""Optional. Configuration for automatic TTL ("time-to-live") of the memories in the Memory Bank. If not set, TTL will not be applied automatically. The TTL can be explicitly set by modifying the `expire_time` of each Memory resource.""", + response: Optional[ReasoningEngine] = Field( + default=None, description="""The created Agent Engine.""" ) -class ReasoningEngineContextSpecMemoryBankConfigDict(TypedDict, total=False): - """Specification for a Memory Bank.""" - - customization_configs: Optional[list[MemoryBankCustomizationConfigDict]] - """Optional. Configuration for how to customize Memory Bank behavior for a particular scope.""" - - disable_memory_revisions: Optional[bool] - """If true, no memory revisions will be created for any requests to the Memory Bank.""" - - generation_config: Optional[ - ReasoningEngineContextSpecMemoryBankConfigGenerationConfigDict - ] - """Optional. Configuration for how to generate memories for the Memory Bank.""" - - similarity_search_config: Optional[ - ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfigDict - ] - """Optional. Configuration for how to perform similarity search on memories. If not set, the Memory Bank will use the default embedding model `text-embedding-005`.""" - - ttl_config: Optional[ReasoningEngineContextSpecMemoryBankConfigTtlConfigDict] - """Optional. Configuration for automatic TTL ("time-to-live") of the memories in the Memory Bank. If not set, TTL will not be applied automatically. The TTL can be explicitly set by modifying the `expire_time` of each Memory resource.""" - - -ReasoningEngineContextSpecMemoryBankConfigOrDict = Union[ - ReasoningEngineContextSpecMemoryBankConfig, - ReasoningEngineContextSpecMemoryBankConfigDict, -] - +class AgentEngineOperationDict(TypedDict, total=False): + """Operation that has an agent engine as a response.""" -class ReasoningEngineContextSpec(_common.BaseModel): - """The configuration for agent engine sub-resources to manage context.""" + name: Optional[str] + """The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.""" - memory_bank_config: Optional[ReasoningEngineContextSpecMemoryBankConfig] = Field( - default=None, - description="""Optional. Specification for a Memory Bank, which manages memories for the Agent Engine.""", - ) + metadata: Optional[dict[str, Any]] + """Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.""" + done: Optional[bool] + """If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.""" -class ReasoningEngineContextSpecDict(TypedDict, total=False): - """The configuration for agent engine sub-resources to manage context.""" + error: Optional[dict[str, Any]] + """The error result of the operation in case of failure or cancellation.""" - memory_bank_config: Optional[ReasoningEngineContextSpecMemoryBankConfigDict] - """Optional. Specification for a Memory Bank, which manages memories for the Agent Engine.""" + response: Optional[ReasoningEngineDict] + """The created Agent Engine.""" -ReasoningEngineContextSpecOrDict = Union[ - ReasoningEngineContextSpec, ReasoningEngineContextSpecDict -] +AgentEngineOperationOrDict = Union[AgentEngineOperation, AgentEngineOperationDict] class CreateAgentEngineConfig(_common.BaseModel): @@ -7720,132 +7910,6 @@ class _CreateAgentEngineRequestParametersDict(TypedDict, total=False): ] -class ReasoningEngine(_common.BaseModel): - """An agent engine.""" - - encryption_spec: Optional[genai_types.EncryptionSpec] = Field( - default=None, - description="""Customer-managed encryption key spec for a ReasoningEngine. If set, this ReasoningEngine and all sub-resources of this ReasoningEngine will be secured by this key.""", - ) - context_spec: Optional[ReasoningEngineContextSpec] = Field( - default=None, - description="""Optional. Configuration for how Agent Engine sub-resources should manage context.""", - ) - create_time: Optional[datetime.datetime] = Field( - default=None, - description="""Output only. Timestamp when this ReasoningEngine was created.""", - ) - description: Optional[str] = Field( - default=None, - description="""Optional. The description of the ReasoningEngine.""", - ) - display_name: Optional[str] = Field( - default=None, - description="""Required. The display name of the ReasoningEngine.""", - ) - etag: Optional[str] = Field( - default=None, - description="""Optional. Used to perform consistent read-modify-write updates. If not set, a blind "overwrite" update happens.""", - ) - labels: Optional[dict[str, str]] = Field( - default=None, description="""Labels for the ReasoningEngine.""" - ) - name: Optional[str] = Field( - default=None, - description="""Identifier. The resource name of the ReasoningEngine. Format: `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}`""", - ) - spec: Optional[ReasoningEngineSpec] = Field( - default=None, description="""Optional. Configurations of the ReasoningEngine""" - ) - update_time: Optional[datetime.datetime] = Field( - default=None, - description="""Output only. Timestamp when this ReasoningEngine was most recently updated.""", - ) - - -class ReasoningEngineDict(TypedDict, total=False): - """An agent engine.""" - - encryption_spec: Optional[genai_types.EncryptionSpecDict] - """Customer-managed encryption key spec for a ReasoningEngine. If set, this ReasoningEngine and all sub-resources of this ReasoningEngine will be secured by this key.""" - - context_spec: Optional[ReasoningEngineContextSpecDict] - """Optional. Configuration for how Agent Engine sub-resources should manage context.""" - - create_time: Optional[datetime.datetime] - """Output only. Timestamp when this ReasoningEngine was created.""" - - description: Optional[str] - """Optional. The description of the ReasoningEngine.""" - - display_name: Optional[str] - """Required. The display name of the ReasoningEngine.""" - - etag: Optional[str] - """Optional. Used to perform consistent read-modify-write updates. If not set, a blind "overwrite" update happens.""" - - labels: Optional[dict[str, str]] - """Labels for the ReasoningEngine.""" - - name: Optional[str] - """Identifier. The resource name of the ReasoningEngine. Format: `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}`""" - - spec: Optional[ReasoningEngineSpecDict] - """Optional. Configurations of the ReasoningEngine""" - - update_time: Optional[datetime.datetime] - """Output only. Timestamp when this ReasoningEngine was most recently updated.""" - - -ReasoningEngineOrDict = Union[ReasoningEngine, ReasoningEngineDict] - - -class AgentEngineOperation(_common.BaseModel): - """Operation that has an agent engine as a response.""" - - name: Optional[str] = Field( - default=None, - description="""The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.""", - ) - metadata: Optional[dict[str, Any]] = Field( - default=None, - description="""Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.""", - ) - done: Optional[bool] = Field( - default=None, - description="""If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.""", - ) - error: Optional[dict[str, Any]] = Field( - default=None, - description="""The error result of the operation in case of failure or cancellation.""", - ) - response: Optional[ReasoningEngine] = Field( - default=None, description="""The created Agent Engine.""" - ) - - -class AgentEngineOperationDict(TypedDict, total=False): - """Operation that has an agent engine as a response.""" - - name: Optional[str] - """The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.""" - - metadata: Optional[dict[str, Any]] - """Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.""" - - done: Optional[bool] - """If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.""" - - error: Optional[dict[str, Any]] - """The error result of the operation in case of failure or cancellation.""" - - response: Optional[ReasoningEngineDict] - """The created Agent Engine.""" - - -AgentEngineOperationOrDict = Union[AgentEngineOperation, AgentEngineOperationDict] - - class DeleteAgentEngineConfig(_common.BaseModel): """Config for deleting agent engine."""