Skip to main content

Module 35: Deploying to Agent Runtime

Deploying to Agent Runtime Banner (Light) Deploying to Agent Runtime Banner (Dark)

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 unified uvicorn app.fast_api_app:app entrypoint that powers Cloud Run and GKEβ€”eliminating Python version mismatches and cloudpickle serialization failures.
  • Zero-Ops Managed Infrastructure: Automatic managed session wiring (VertexAiSessionService), built-in A2A + native :streamQuery serving, Terraform Infrastructure-as-Code (google_vertex_ai_reasoning_engine with lifecycle.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​

Agent Runtime Architecture & Authorization Lifecycle (Light) Agent Runtime Architecture & Authorization Lifecycle (Dark) 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 via attach_reasoning_engine_routes(app), constructing an internal adapter to handle native :query and :streamQuery invocations (used by the Cloud Console Playground, agents-cli run --mode adk, and Gemini Enterprise ADK registration).
  • Built-in A2A & ADK HTTP Routes via /api Passthrough: Agent Runtime exposes your container's HTTP routes externally under https://{location}-aiplatform.googleapis.com/v1/{resource}/api/{container_path}β€”making both /run_sse and 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.py defaults to shared://session (in-memory) so agents-cli run and agents-cli playground work offline with zero setup.
  • At cloud runtime, Agent Runtime injects GOOGLE_CLOUD_AGENT_ENGINE_ID, and app/app_utils/services.py automatically upgrades the runner to VertexAiSessionService (and upgrades artifacts to GcsArtifactService when LOGS_BUCKET_NAME is set).
  • Critical Rule: Never hardcode or pass a custom --session-type / session_type override when targeting agent_runtime. If migrating a project that sets session_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-wait to start the rollout and return your terminal immediately, then poll progress with agents-cli deploy --status (and audit live instances anytime with agents-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" so gemini-3.8-flash resolves on the global endpoint.
  • When the rollout finishes (synchronously or via --status), agents-cli writes deployment_metadata.json:
    {
    "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"
    }
    In Module 36, agents-cli publish gemini reads 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:

CapabilityCLI / Scaffold FlagsOperational Behavior & Requirements
Agent Identityagents-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 Gatewayagents-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).
🎯 Knowledge CheckSelect Best Answer

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 deploy builds your root Dockerfile on Agent Runtime, serving uvicorn app.fast_api_app:app for both native :streamQuery (--mode adk) and /api HTTP passthrough A2A routes (--mode a2a).
  • Automatic Managed Sessions: Agent Runtime automatically upgrades shared://session to VertexAiSessionService when GOOGLE_CLOUD_AGENT_ENGINE_ID is presentβ€”never hardcode custom session_type overrides when targeting agent_runtime.
  • Async Rollouts & Metadata Handoff: Use agents-cli deploy --no-wait and agents-cli deploy --status to manage 5–10 minute container builds cleanly; completion writes deployment_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-gateway at scaffold time), PSC-I --network-attachment, and CMEK (--key) enforce zero-trust identity, network perimeter inspection, and customer-managed encryption without touching app/agent.py.
πŸ“–

35: Deploying to Agent Runtime(Theory & Overview)

Part 7: Cloud Runtimes & Enterprise β€’ Module 35

Overall Course Progress:
0%(0/98)
Next Step: Challenge Lab πŸ§ͺ β†’