Skip to main content

Lab 32: Deploying Support Ops Agent to Cloud Run with Google Agents CLI

Goalโ€‹

In this lab, you will carry support-ops-agent (gemini-3.8-flash) from its local prototype into production on Google Cloud Run using the agents-cli Golden Path: enhancing the project in place with Cloud Run Terraform & CI/CD scaffolding (scaffold enhance), deploying with clean infrastructure-vs-model region separation (agents-cli deploy), querying both its built-in A2A and ADK SSE endpoints live in the cloud, and grading evaluation traces generated directly from the deployed Cloud Run URL.

Environment setup:

  • 1-Click Launch (Browser): Open in GitHub CodespacesOpen in Google Cloud Shell
  • Local machine: If you're continuing the course in sequence, cd into the adk-training project you created in Module 2 and skip the block below -- your environment and dependencies already carry forward. If you're starting fresh at this module, create that project first:
    uv init adk-training --python 3.10 && cd adk-training
    uv add "google-adk>=2.1.0" python-dotenv
  • DevContainer / Codespaces (Alternative): If you opened this repository in a DevContainer or GitHub Codespaces, Python 3.11, uv, gcloud, and all core ADK dependencies are pre-installed in your container environment.

Prerequisitesโ€‹

  • A Google Cloud Project with billing enabled and Owner or Editor permissions.
  • Google Cloud CLI installed and authenticated:
    gcloud auth login
    gcloud auth application-default login
    gcloud config set project YOUR_PROJECT_ID
  • Enable the required Google Cloud APIs in your project:
    gcloud services enable \
    run.googleapis.com \
    cloudbuild.googleapis.com \
    artifactregistry.googleapis.com \
    aiplatform.googleapis.com \
    secretmanager.googleapis.com \
    --project=YOUR_PROJECT_ID
  • google-agents-cli installed (uv tool install google-agents-cli).

Step 1: Prepare or Fast-Bootstrap support-ops-agentโ€‹

  • Continuing from Module 31? Simply enter your existing support-ops-agent/ directory:

    cd /path/to/your/adk-training/support-ops-agent
    agents-cli info
  • Starting fresh at Module 32? Run this 10-second standalone bootstrap from adk-training/ (do not mkdir support-ops-agent beforehand) to pull the canonical app/agent.py and evaluation dataset:

    cd /path/to/your/adk-training
    agents-cli scaffold create support-ops-agent --agent adk --prototype --agent-guidance-filename GEMINI.md
    curl -fsSL https://mauripsale.github.io/doc-adk-training/samples/part6/agent.py -o support-ops-agent/app/agent.py
    curl -fsSL https://mauripsale.github.io/doc-adk-training/samples/part6/basic-dataset.json -o support-ops-agent/tests/eval/datasets/basic-dataset.json
    cd support-ops-agent

Verify that app/agent.py defines root_agent (name="support_ops_agent", MODEL = "gemini-3.8-flash") and app = App(root_agent=root_agent, name="app"), and that root_agent_name: support_ops_agent is set in agents-cli-manifest.yaml.


Step 2: Enhance the Prototype for Cloud Run (scaffold enhance)โ€‹

Upgrade support-ops-agent in place to add Cloud Run Terraform modules, GitHub Actions CI/CD workflows, and Locust load tests while leaving app/agent.py and .env completely intact:

  1. Export your project ID and Cloud Run region, then run scaffold enhance:

    export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT_ID
    export DEPLOY_REGION=us-central1

    agents-cli scaffold enhance . \
    --deployment-target cloud_run \
    --cicd-runner github_actions \
    --region "$DEPLOY_REGION"

    agents-cli install
  2. Inspect the generated production artifacts:

    • agents-cli-manifest.yaml: Confirm deployment_target: cloud_run, cicd_runner: github_actions, and region: us-central1 are recorded.
    • deployment/terraform/single-project/service.tf: Inspect the google_cloud_run_v2_service definition, including min_instance_count, max_instance_request_concurrency, CPU/memory limits, and the runtime app_sa service account.
    • tests/load_test/load_test.py: Review the generated Locust load test used to benchmark concurrency and latency under load.
    • app/agent.py: Confirm your stateful support_ops_agent code was preserved untouched!

Step 3: Deploy support-ops-agent to Cloud Run (agents-cli deploy)โ€‹

Now package, build, and deploy the container to Cloud Run in us-central1 while pointing GOOGLE_CLOUD_LOCATION inside the container to the global Gemini Enterprise / Vertex AI endpoint for gemini-3.8-flash.

  1. Preview the exact deployment command with --dry-run:

    agents-cli deploy \
    --project "$GOOGLE_CLOUD_PROJECT" \
    --region "$DEPLOY_REGION" \
    --env-vars "GOOGLE_GENAI_USE_ENTERPRISE=1,GOOGLE_CLOUD_LOCATION=global" \
    --no-confirm-project \
    --dry-run

    Inspect the printed gcloud command to see how agents-cli configures --memory 4Gi, --cpu 1, --concurrency 8, --min-instances 0, and your runtime environment variables.

  2. Execute the live Cloud Run rollout:

    agents-cli deploy \
    --project "$GOOGLE_CLOUD_PROJECT" \
    --region "$DEPLOY_REGION" \
    --env-vars "GOOGLE_GENAI_USE_ENTERPRISE=1,GOOGLE_CLOUD_LOCATION=global" \
    --no-confirm-project

    Wait 2โ€“4 minutes while Cloud Build builds the uv-managed Dockerfile, pushes the image to Artifact Registry, and rolls out the Cloud Run revision.


Step 4: Query & Evaluate the Live Cloud Run Service with agents-cliโ€‹

  1. Capture the live Cloud Run SERVICE_URL:

    SERVICE_URL=$(gcloud run services describe support-ops-agent \
    --region="$DEPLOY_REGION" \
    --project="$GOOGLE_CLOUD_PROJECT" \
    --format='value(status.url)')
    echo "Live Service URL: $SERVICE_URL"
  2. Test the live Agent-to-Agent (A2A) protocol endpoint (--mode a2a): agents-cli automatically attaches your Google Cloud identity token, fetches $SERVICE_URL/a2a/app/.well-known/agent-card.json, and invokes the agent over A2A JSON-RPC:

    agents-cli run "Investigate ticket TCK-1042 and check SLA." \
    --url "$SERVICE_URL" \
    --mode a2a

    Verify that the cloud service looks up TCK-1042, cites the 15 minutes enterprise P1 SLA, and escalates to 24/7 P1 SRE Oncall!

  3. Test the live ADK SSE streaming endpoint (--mode adk):

    agents-cli run "Check ticket TCK-2088." \
    --url "$SERVICE_URL" \
    --mode adk \
    --app-name app

    Verify that it returns the status (investigating) and standard P3 SLA (24 business hours) for Northwind Retail.

  4. Run remote cloud trace generation + automated grading against the live URL: Drive the evaluation dataset from tests/eval/datasets/basic-dataset.json directly against your deployed Cloud Run container and grade the captured traces:

    agents-cli eval generate --url "$SERVICE_URL" --app-name app && agents-cli eval grade

    Inspect the printed score summary and the new artifacts/grade_results/results_<timestamp>.html report to confirm parity between local and cloud execution!


Step 5: Under the Hood Reference & Revision Rollbackโ€‹

Under the Hood Reference: adk deploy cloud_run, Instant Traffic Rollback & Cleanup

When working on standalone single-folder ADK experiments outside an agents-cli repository, the core ADK CLI also offers uv run adk deploy cloud_run, which synthesizes a temporary Dockerfile and runs gcloud run deploy:

# Standalone ADK CLI alternative (for non-scaffolded single-agent folders):
uv run adk deploy cloud_run \
--project="$GOOGLE_CLOUD_PROJECT" \
--region="$DEPLOY_REGION" \
--env GOOGLE_CLOUD_LOCATION=global \
app/

Instant Cloud Run Revision Rollback (Zero-Commit Recovery): While GitOps rollback (reverting a commit on main) is the primary production strategy, Cloud Run keeps immutable revisions so you can shift 100% of traffic back to a known-good revision in seconds:

gcloud run revisions list \
--service=support-ops-agent \
--region="$DEPLOY_REGION" \
--project="$GOOGLE_CLOUD_PROJECT"

gcloud run services update-traffic support-ops-agent \
--to-revisions=REVISION_NAME=100 \
--region="$DEPLOY_REGION" \
--project="$GOOGLE_CLOUD_PROJECT"

Optional Cost Cleanup: Because agents-cli deploy sets --min-instances 0 by default, an idle service incurs zero compute cost (and keeping support-ops-agent live lets you register its A2A endpoint in Module 36!). Whenever you want to delete the Cloud Run service completely, run:

gcloud run services delete support-ops-agent \
--region="$DEPLOY_REGION" \
--project="$GOOGLE_CLOUD_PROJECT" \
--quiet

Having Trouble?โ€‹

Check the troubleshooting guide and complete reference solution in lab-solution.md or unlock the Reference Solution Vault below.

Lab Summaryโ€‹

Congratulations! You have promoted support-ops-agent to Google Cloud Run using the end-to-end agents-cli Golden Path:

  • Upgraded a --prototype project in place via agents-cli scaffold enhance . --deployment-target cloud_run without modifying app/agent.py.
  • Previewed (--dry-run) and deployed the container with regional separation (--region us-central1 + GOOGLE_CLOUD_LOCATION=global).
  • Invoked the live authenticated Cloud Run service over both A2A (--mode a2a) and ADK SSE (--mode adk --app-name app), and ran agents-cli eval generate --url ... && agents-cli eval grade against production HTTP endpoints.

Self-Reflection Questionsโ€‹

  • Why does agents-cli deploy default to --no-allow-unauthenticated on Cloud Run, and how would you expose a browser-accessible internal tool safely to employees without writing custom login code?
  • If load testing with tests/load_test/load_test.py triggers container OOM restarts when you raise --concurrency from 8 to 32, which flag should you scale alongside --concurrency and why?
  • What happens to active conversation history in support-ops-agent when a Cloud Run instance scales down to zero under the default in_memory session configuration, and which scaffold enhance flag solves this for stateful production apps?

๐Ÿ” Reference Solution Vaultโ€‹

๐Ÿงช

32: Deploying to Cloud Run(Challenge Lab)

Part 7: Cloud Runtimes & Enterprise โ€ข Module 32