Module 35: Deploying to Agent Runtime

Theoryβ
Completing the Part 7 Cloud Runtime Triadβ
In Modules 32 and 33, you deployed our stateful Python support-ops-agent (gemini-3.8-flash) to serverless containers on Google Cloud Run and orchestrated pods on GKE Autopilot. Google Cloud's Agent Runtime (formerly Vertex AI Agent Engine) completes the Part 7 compute triad as a purpose-built, fully managed runtime in the Gemini Enterprise Agent Platform.
Container-First Architecture (Why Legacy Pickle Packaging Was Retired)β
Modern production deployments to Agent Runtime use google-agents-cli (agents-cli scaffold enhance . --deployment-target agent_runtime + agents-cli deploy) rather than legacy pickle-based vertexai.agent_engines.create() scripts:
- Deterministic Container Builds: Agent Runtime builds your container image directly from your project's root
Dockerfile, running the exact same unifieduvicorn app.fast_api_app:appentrypoint that powers Cloud Run and GKEβeliminating Python version mismatches andcloudpickleserialization failures. - Zero-Ops Managed Infrastructure: Automatic managed session wiring (
VertexAiSessionService), built-in A2A + native:streamQueryserving, Terraform Infrastructure-as-Code (google_vertex_ai_reasoning_enginewithlifecycle.ignore_changes), and GitOps CI/CD promotion. - First-Class Enterprise Security: Native per-agent Agent Identity (
--agent-identity), Agent Gateway ingress/egress inspection (--agent-gateway-ingress/--agent-gateway-egress), Customer-Managed Encryption Keys (--key), Private Service Connect interfaces (--network-attachment), and managed OAuth 2.0 user consent for Gemini Enterprise (Module 36).
How Container-Based Agent Runtime Worksβ
Figure: Managed container execution, automatic session persistence, and governed networking in Agent Runtime.
1. Unified Dockerfile & Dual-Protocol Surfaceβ
When you enhance support-ops-agent with agents-cli scaffold enhance . --deployment-target agent_runtime, app/fast_api_app.py configures a single FastAPI container (get_fast_api_app) that simultaneously serves:
- Native Reasoning Engine Contract (
/api/reasoning_engine&/api/stream_reasoning_engine): Added viaattach_reasoning_engine_routes(app), constructing an internal adapter to handle native:queryand:streamQueryinvocations (used by the Cloud Console Playground,agents-cli run --mode adk, and Gemini Enterprise ADK registration). - Built-in A2A & ADK HTTP Routes via
/apiPassthrough: Agent Runtime exposes your container's HTTP routes externally underhttps://{location}-aiplatform.googleapis.com/v1/{resource}/api/{container_path}βmaking both/run_sseand your live A2A Agent Card (/api/a2a/app/.well-known/agent-card.json) reachable with standard Google Cloud IAM credentials (agents-cli run --mode a2a).
2. Managed Sessions (VertexAiSessionService) β Do Not Override session_type!β
On Cloud Run and GKE, you explicitly choose --session-type (in_memory, cloud_sql, or agent_platform_sessions). On Agent Runtime, sessions are managed natively by the platform:
- Locally,
app/app_utils/services.pydefaults toshared://session(in-memory) soagents-cli runandagents-cli playgroundwork offline with zero setup. - At cloud runtime, Agent Runtime injects
GOOGLE_CLOUD_AGENT_ENGINE_ID, andapp/app_utils/services.pyautomatically upgrades the runner toVertexAiSessionService(and upgrades artifacts toGcsArtifactServicewhenLOGS_BUCKET_NAMEis set). - Critical Rule: Never hardcode or pass a custom
--session-type/session_typeoverride when targetingagent_runtime. If migrating a project that setssession_type, clear it so Agent Runtime's managed session backend takes over cleanly.
3. Non-Blocking Rollouts (--no-wait & --status) and deployment_metadata.jsonβ
Because Agent Runtime compiles your Dockerfile remotely and provisions managed infrastructure, deployments typically take 5β10 minutes:
- Pass
--no-waitto start the rollout and return your terminal immediately, then poll progress withagents-cli deploy --status(and audit live instances anytime withagents-cli deploy --list). - Separate infrastructure region from model endpoint: deploy the engine in a concrete region (
--region us-central1) while injecting--env-vars "GOOGLE_GENAI_USE_ENTERPRISE=1,GOOGLE_CLOUD_LOCATION=global"sogemini-3.8-flashresolves on the global endpoint. - When the rollout finishes (synchronously or via
--status),agents-cliwritesdeployment_metadata.json:In Module 36,{
"remote_agent_runtime_id": "projects/PROJECT/locations/us-central1/reasoningEngines/ENGINE_ID",
"deployment_target": "agent_runtime",
"is_a2a": true,
"agent_directory": "app",
"deployment_timestamp": "2026-12-01T10:30:00.000+00:00"
}agents-cli publish geminireads this file automatically for zero-flag ADK registration into Gemini Enterprise!
Enterprise Security & Governance Controls on Agent Runtimeβ
Agent Runtime unlocks first-class enterprise security capabilities directly from agents-cli:
| Capability | CLI / Scaffold Flags | Operational Behavior & Requirements |
|---|---|---|
| Agent Identity | agents-cli deploy --agent-identity (or --agent-runtime-identity-default agent_identity) | Assigns a dedicated, verifiable workload identity to the Agent Runtime resource instead of sharing a broad project service account. Required before binding an Agent Gateway. |
| Agent Gateway | agents-cli scaffold enhance . --agent-gateway + deploy --agent-gateway-egress <GW> / --agent-gateway-ingress <GW> | Routes inbound (CLIENT_TO_AGENT) and/or outbound (AGENT_TO_ANYWHERE) traffic through a governed Agent Gateway (projects/PROJECT/locations/REGION/agentGateways/GATEWAY). Because an egress gateway performs TLS inspection, you must scaffold/enhance with --agent-gateway so the Dockerfile trusts the platform-injected AGENT_GATEWAY_ROOT_CERTIFICATES build arg. |
| Customer-Managed Encryption (CMEK) | agents-cli deploy --key <KMS_KEY_RESOURCE> | Encrypts the Agent Runtime instance at creation time using your single-region Cloud KMS key (projects/KEY_PROJECT/locations/REGION/keyRings/RING/cryptoKeys/KEY). Grant roles/cloudkms.cryptoKeyEncrypterDecrypter to both service-PROJECT_NUMBER@gcp-sa-aiplatform.iam.gserviceaccount.com and service-PROJECT_NUMBER@gcp-sa-aiplatform-re.iam.gserviceaccount.com first. Keys are set at creation time only (--update-only cannot rotate a CMEK key in place). |
| Private VPC (PSC-I) | agents-cli deploy --network-attachment <ATTACHMENT> | Enables private VPC egress via Private Service Connect interfaces (with optional --dns-peering-domain, --dns-peering-project, and --dns-peering-network). |
When deploying a scaffolded Python ADK agent ('support-ops-agent') to Agent Runtime using 'agents-cli', how are durable multi-turn sessions configured, and what is required before binding an outbound '--agent-gateway-egress'?
Key Takeawaysβ
- 100% Container-Based Agent Runtime:
agents-cli deploybuilds your rootDockerfileon Agent Runtime, servinguvicorn app.fast_api_app:appfor both native:streamQuery(--mode adk) and/apiHTTP passthrough A2A routes (--mode a2a). - Automatic Managed Sessions: Agent Runtime automatically upgrades
shared://sessiontoVertexAiSessionServicewhenGOOGLE_CLOUD_AGENT_ENGINE_IDis presentβnever hardcode customsession_typeoverrides when targetingagent_runtime. - Async Rollouts & Metadata Handoff: Use
agents-cli deploy --no-waitandagents-cli deploy --statusto manage 5β10 minute container builds cleanly; completion writesdeployment_metadata.json("agent_directory": "app"), powering zero-flag Gemini Enterprise publishing in Module 36. - Enterprise Governance Ready: First-class flags for
--agent-identity,--agent-gateway-egress/--agent-gateway-ingress(paired with--agent-gatewayat scaffold time), PSC-I--network-attachment, and CMEK (--key) enforce zero-trust identity, network perimeter inspection, and customer-managed encryption without touchingapp/agent.py.