Feat: Add Agent Engine deployment support#335
Conversation
- 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
| .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, | ||
| ) |
There was a problem hiding this comment.
Those are a duplicated options across several cli commands definitions, consider moving as a const and just reuse it everywhere
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Refactored the deployment structure:
- Created a new nested dev/src/cli/deploy folder.
- Moved agent engine deployment to it's own file and renamed cli_deploy.ts to cli_deploy_cloud_run.ts
- Put common log into deploy_utils.ts file
- updated tests accordingly
- 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
… resolve styling violation
| stagingBucket?: string; | ||
| } | ||
|
|
||
| export function createDockerFileContent(options: { |
There was a problem hiding this comment.
I think we can reuse this method as well
There was a problem hiding this comment.
Extracted createDockerFileContent into deploy_utils.ts and reused it across both modules.
| )}`; | ||
| } | ||
|
|
||
| async function createDockerFile( |
There was a problem hiding this comment.
this can be reused in 2 files
There was a problem hiding this comment.
Extracted createDockerFile to deploy_utils.ts to share the common setup logic across both deployment implementations.
|
|
||
| const DEFAULT_MAX_ATTEMPTS = 30; | ||
|
|
||
| export interface DeployToAgentEngineOptions { |
There was a problem hiding this comment.
I think it can be reused
There was a problem hiding this comment.
Created a shared BaseDeployOptions interface in deploy_utils.ts . Both DeployToAgentEngineOptions and DeployToCloudRunOptions now cleanly inherit from it.
| @@ -0,0 +1,284 @@ | |||
| /** | |||
There was a problem hiding this comment.
Please amke sure that all reusable parts moved to deploy_utils.ts and reused everywhere.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
How this process differ from deploy to cloud run?
There was a problem hiding this comment.
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:
-
It submits the deployment bundle and builds/pushes the Docker container image via gcloud builds submit --tag
.
-
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.
…s across Cloud Run and Agent Engine deployment modules
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
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 aliasreasoning_engine) under the CLIdeploynamespace. This command automates containerization and registration into Vertex AI Agent Engine by performing the following steps:client.agentEnginesInternal.createInternal) to register the agent as aReasoningEnginepointing to the uploaded image.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:
npx vitest run dev/test/cli/cli_deploy_agent_engine_test.tsChecklist