Deploy an agent

To deploy an agent on Vertex AI Agent Engine, use the following steps:

  1. Complete prerequisites.
  2. (Optional) Configure your agent for deployment.
  3. Create an AgentEngine instance.
  4. (Optional) Get the agent resource ID.
  5. (Optional) List the supported operations.
  6. (Optional) Grant the deployed agent permissions.

You can also use Agent Starter Pack templates for deployment.

Prerequisites

Before you deploy an agent, make sure you have completed the following tasks:

  1. Set up your environment.
  2. Develop an agent.

(Optional) Configure your agent for deployment

You can make the following optional configurations for your agent:

Create an AgentEngine instance

To deploy the agent on Vertex AI, use client.agent_engines.create to pass in the local_agent object along with any optional configurations:

remote_agent = client.agent_engines.create(
    agent=local_agent,                                  # Optional.
    config={
        "requirements": requirements,                   # Optional.
        "extra_packages": extra_packages,               # Optional.
        "gcs_dir_name": gcs_dir_name,                   # Optional.
        "display_name": display_name,                   # Optional.
        "description": description,                     # Optional.
        "env_vars": env_vars,                           # Optional.
        "build_options": build_options,                 # Optional.
        "service_account": service_account,             # Optional.
        "min_instances": min_instances,                 # Optional.
        "max_instances": max_instances,                 # Optional.
        "resource_limits": resource_limits,             # Optional.
        "container_concurrency": container_concurrency, # Optional
        "encryption_spec": encryption_spec,             # Optional.
    },
)

Deployment takes a few minutes, during which the following steps happen in the background:

  1. A bundle of the following artifacts are generated locally:

    • *.pkl a pickle file corresponding to local_agent.
    • requirements.txt a text file containing the package requirements.
    • dependencies.tar.gz a tar file containing any extra packages.
  2. The bundle is uploaded to Cloud Storage (under the corresponding folder) for staging the artifacts.

  3. The Cloud Storage URIs for the respective artifacts are specified in the PackageSpec.

  4. The Vertex AI Agent Engine service receives the request and builds containers and starts HTTP servers on the backend.

Deployment latency depends on the total time it takes to install required packages. Once deployed, remote_agent corresponds to an instance of local_agent that is running on Vertex AI and can be queried or deleted. It is separate from local instances of the agent.

The remote_agent object corresponds to an AgentEngine class that contains the following attributes:

(Optional) Get the agent resource ID

Each deployed agent has a unique identifier. You can run the following command to get the resource name for your deployed agent:

remote_agent.api_resource.name

The response should look like the following string:

"projects/PROJECT_NUMBER/locations/LOCATION/reasoningEngines/RESOURCE_ID"

where

  • PROJECT_ID is the Google Cloud project ID where the deployed agent runs.

  • LOCATION is the region where the deployed agent runs.

  • RESOURCE_ID is the ID of the deployed agent as a reasoningEngine resource.

(Optional) List the supported operations

Each deployed agent has a list of supported operations. You can run the following command to get the list of operations supported by the deployed agent:

remote_agent.operation_schemas()

The schema for each operation is a dictionary that documents the information of a method for the agent that you can call. The set of supported operations depends on the framework you used to develop your agent:

(Optional) Grant the deployed agent permissions

If the deployed agent needs to be granted any additional permissions, follow the instructions in Set up the identity and permissions for your agent.

What's next