|
|
Deploying ADK Agents to Vertex AI Agent Engine
Author: Venkata Sudhakar
When your ADK agent is tested and ready for production, Vertex AI Agent Engine is the recommended deployment target. Agent Engine is a fully managed Google Cloud service that handles infrastructure provisioning, automatic scaling, session persistence across requests, and security - you focus on agent logic, Google handles everything else. Your ADK agent code runs unchanged in Agent Engine - the only difference is the AdkApp wrapper and deployment commands. Once deployed, Agent Engine exposes your agent via a managed API with IAM authentication, audit logging, and per-project quota management. Deployment uses the vertexai Python SDK. You wrap your ADK agent in an AdkApp class, call vertexai.agent_engines.AdkApp.create() to deploy it to Agent Engine, and receive a remote_app handle. You then interact with it using remote_app.stream_query() exactly as you would call runner.run() locally - the interface is identical. Agent Engine automatically uses cloud-based managed sessions so conversation history persists across multiple API calls to the same session, even when running on distributed infrastructure. The below example deploys the ShopMax customer service agent from Tutorial 312 to Vertex AI Agent Engine - showing the full deployment workflow from local testing to cloud production and how to query the deployed agent.
Deploying to Vertex AI Agent Engine and querying the live deployment,
It gives the following output for the deployment and queries,
Testing locally...
Local: {"author": "shopmax_support", "content": {"parts": [{"text": "Your Samsung 4K TV..."}]}}
Deploying to Agent Engine...
Deployed! Resource name: projects/my-project/locations/us-central1/reasoningEngines/1234567890
Querying deployed agent...
Customer: Where is my order ORD-88421?
Agent: Your Samsung 4K TV from order ORD-88421 is out for delivery and
expected today by 7pm. Watch for an SMS when it is nearby!
Customer: Is iPhone 15 Pro in stock in Delhi?
Agent: Yes, iPhone 15 Pro has 7 units available in Delhi.
You can order online for same or next-day delivery.
Agent updated to v2 with zero downtime
# Local testing and production use identical code - only .create() changes
# Agent Engine handles: scaling, sessions, IAM, audit logs, health checks
# Session state persists across API calls - same user/session = same conversation
The ADK CLI provides a simple command-line deployment workflow,
Deploying agent to Vertex AI Agent Engine...
Uploading agent code...
Provisioning managed infrastructure...
Agent deployed successfully!
Resource: projects/my-project/locations/us-central1/reasoningEngines/1234567890
Endpoint: https://us-central1-aiplatform.googleapis.com/v1/...
Status: ACTIVE
# Agent is now live, scaling from 0 to 1000s of concurrent users automatically
Agent Engine deployment checklist: test your agent thoroughly with the ADK eval framework (Tutorial 318) before deploying. Use a staging deployment in a separate GCP project before promoting to production. Set up Cloud Monitoring alerts on error rates and latency - Agent Engine emits standard GCP metrics. For multi-region deployments, deploy to multiple regions and use a load balancer - Agent Engine does not do cross-region routing automatically. Each deployed agent version has a unique resource name; keep the last 2-3 versions available so you can roll back instantly if a new deployment has quality issues.
|
|