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,
cdinto theadk-trainingproject 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
OwnerorEditorpermissions. - 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-cliinstalled (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 notmkdir support-ops-agentbeforehand) to pull the canonicalapp/agent.pyand 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:
-
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 -
Inspect the generated production artifacts:
agents-cli-manifest.yaml: Confirmdeployment_target: cloud_run,cicd_runner: github_actions, andregion: us-central1are recorded.deployment/terraform/single-project/service.tf: Inspect thegoogle_cloud_run_v2_servicedefinition, includingmin_instance_count,max_instance_request_concurrency, CPU/memory limits, and the runtimeapp_saservice 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 statefulsupport_ops_agentcode 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.
-
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-runInspect the printed
gcloudcommand to see howagents-cliconfigures--memory 4Gi,--cpu 1,--concurrency 8,--min-instances 0, and your runtime environment variables. -
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-projectWait 2โ4 minutes while Cloud Build builds the
uv-managedDockerfile, 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โ
-
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" -
Test the live Agent-to-Agent (A2A) protocol endpoint (
--mode a2a):agents-cliautomatically 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 a2aVerify that the cloud service looks up
TCK-1042, cites the15 minutesenterprise P1 SLA, and escalates to24/7 P1 SRE Oncall! -
Test the live ADK SSE streaming endpoint (
--mode adk):agents-cli run "Check ticket TCK-2088." \
--url "$SERVICE_URL" \
--mode adk \
--app-name appVerify that it returns the status (
investigating) and standard P3 SLA (24 business hours) for Northwind Retail. -
Run remote cloud trace generation + automated grading against the live URL: Drive the evaluation dataset from
tests/eval/datasets/basic-dataset.jsondirectly against your deployed Cloud Run container and grade the captured traces:agents-cli eval generate --url "$SERVICE_URL" --app-name app && agents-cli eval gradeInspect the printed score summary and the new
artifacts/grade_results/results_<timestamp>.htmlreport 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
--prototypeproject in place viaagents-cli scaffold enhance . --deployment-target cloud_runwithout modifyingapp/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 ranagents-cli eval generate --url ... && agents-cli eval gradeagainst production HTTP endpoints.
Self-Reflection Questionsโ
- Why does
agents-cli deploydefault to--no-allow-unauthenticatedon 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.pytriggers container OOM restarts when you raise--concurrencyfrom8to32, which flag should you scale alongside--concurrencyand why? - What happens to active conversation history in
support-ops-agentwhen a Cloud Run instance scales down to zero under the defaultin_memorysession configuration, and whichscaffold enhanceflag solves this for stateful production apps?
๐ Reference Solution Vaultโ
Official Solution Vault โ Module 32
Locked Challenge โ Active Pedagogical Socratic Gate