Skip to content

Feat: Add Agent Engine deployment support#335

Open
AmaadMartin wants to merge 10 commits into
google:mainfrom
AmaadMartin:feat/agent-engine-deployment
Open

Feat: Add Agent Engine deployment support#335
AmaadMartin wants to merge 10 commits into
google:mainfrom
AmaadMartin:feat/agent-engine-deployment

Conversation

@AmaadMartin
Copy link
Copy Markdown
Collaborator

@AmaadMartin AmaadMartin commented May 8, 2026

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

  1. Link to an existing issue (if applicable):
    Add support for deployment on Agent Engine #85

Closes: #85

Problem:
The ADK CLI for JavaScript/TypeScript (adk-js) only supports deploying agents to Google Cloud Run. There is no native CLI support to deploy agents directly to the Vertex AI Agent Engine (Reasoning Engine), which is a managed runtime supporting persistent session services (VertexAiSessionService) and native enterprise integrations.

Solution:
Implemented a new deployment subcommand agent_engine (and its alias reasoning_engine) under the CLI deploy namespace. This command automates containerization and registration into Vertex AI Agent Engine by performing the following steps:

  1. Packages agent logic and builds a node.js docker environment using a custom Dockerfile.
  2. Builds and submits the container image to Artifact Registry using Google Cloud Builds.
  3. Invokes the Vertex AI Client SDK (client.agentEnginesInternal.createInternal) to register the agent as a ReasoningEngine pointing to the uploaded image.
  4. Polls the long-running operation until deployment completes.

Testing Plan
Unit tests have been introduced to cover container packaging, Cloud Build submission, operation polling, default project/region resolution, package.json verification, and timeout/failure scenarios.

Unit Tests:

  • Added comprehensive tests in cli_deploy_agent_engine_test.ts
  • Ran tests using npx vitest run dev/test/cli/cli_deploy_agent_engine_test.ts
  • Results: 7 tests passed successfully.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end (mocked flow verified).

- Registered double commands 'agent_engine' and 'reasoning_engine' in ADK CLI
- Implemented deployToAgentEngine build and Vertex AI reasoning engine registration pipelines
- Added exhaustive unit tests to cover 100% of implementation with mocks
Comment thread dev/src/cli/cli.ts Outdated
Comment on lines +426 to +456
.option(
'--project [string]',
'Optional. Google Cloud project to deploy the agent. If not set, default project from gcloud config is used',
)
.option(
'--region [string]',
'Optional. Google Cloud region to deploy the agent. If not set, default run/region from gcloud config is used',
)
.option(
'--display_name [string]',
'Optional. The display name for the Reasoning Engine. Defaults to agent directory name.',
)
.option(
'--description [string]',
'Optional. The description for the Reasoning Engine.',
)
.option(
'--temp_folder [string]',
'Optional. Temp folder for the generated source files (default: a timestamped folder in the system temp directory).',
getTempDir('agent_engine_deploy_src'),
)
.option(
'--adk_version [string]',
'Optional. ADK version to use. If not set, default to the latest version available on npm',
'latest',
)
.option(
'--with_ui [boolean]',
'Optional. Deploy ADK Web UI if set. (default: deploy ADK API server only)',
false,
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are a duplicated options across several cli commands definitions, consider moving as a const and just reuse it everywhere

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've refactored the option definitions for --project, --region, --adk_version, --with_ui, --display_name, and --description into reusable constants at the file level. Cloud_run, agent_engine, and reasoning_engine all use them now.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create new folder deploy and move this file there file as well as well as existing cli_deploy.ts. Rename cli_deploy.ts to cli_deploy_cloud_run.ts. Move common parts to deploy_utils.ts file and reuse them in this file and cli_deploy_cloud_run.ts.

Thanks

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored the deployment structure:

  1. Created a new nested dev/src/cli/deploy folder.
  2. Moved agent engine deployment to it's own file and renamed cli_deploy.ts to cli_deploy_cloud_run.ts
  3. Put common log into deploy_utils.ts file
  4. updated tests accordingly

Amaad Martin and others added 7 commits May 12, 2026 09:28
- Moved Cloud Run and Agent Engine deployment pipelines into a nested deploy/ folder
- Extracted shared CLI compilation, workspace copying, package validation, and gcloud configuration tasks into deploy_utils.ts
- Deduped CLI options (project, region, display name, description, adk version, with ui) as reusable constants inside cli.ts
- Renamed and updated corresponding unit test modules under dev/test/cli
stagingBucket?: string;
}

export function createDockerFileContent(options: {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can reuse this method as well

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted createDockerFileContent into deploy_utils.ts and reused it across both modules.

)}`;
}

async function createDockerFile(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be reused in 2 files

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted createDockerFile to deploy_utils.ts to share the common setup logic across both deployment implementations.


const DEFAULT_MAX_ATTEMPTS = 30;

export interface DeployToAgentEngineOptions {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be reused

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created a shared BaseDeployOptions interface in deploy_utils.ts . Both DeployToAgentEngineOptions and DeployToCloudRunOptions now cleanly inherit from it.

@@ -0,0 +1,284 @@
/**
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please amke sure that all reusable parts moved to deploy_utils.ts and reused everywhere.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All shared data structures, option interfaces, and Dockerfile building utilities have been centralized into deploy_utils.ts and reused uniformly across both deployment mechanisms.

await saveToFile(dockerFilePath, createDockerFileContent(options));
}

export async function deployToAgentEngine(options: DeployToAgentEngineOptions) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How this process differ from deploy to cloud run?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploying to Cloud Run relies on gcloud run deploy --source, which delegates both source packaging and serverless container deployment to a single unified Google Cloud CLI workflow.

Deploying to Agent Engine (Vertex AI Reasoning Engine) targets Vertex AI, which does not have a single-source CLI deploy mechanism in gcloud. Therefore, deployToAgentEngine orchestrates a customized two-stage pipeline:

  1. It submits the deployment bundle and builds/pushes the Docker container image via gcloud builds submit --tag .

  2. It programmatically invokes the Vertex AI GenAI SDK (client.agentEnginesInternal.createInternal) to spin up and register the Reasoning Engine runtime instance using the successfully pushed container image.

Amaad Martin and others added 2 commits May 29, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for deployment on Agent Engine

2 participants